The Preliminary Contest for ICPC Asia Shenyang 2019 H
2024-09-02 15:32:23
H. Texas hold'em Poker
思路:根据每个牌型分等级,然后排序按照等级优先,最大值次之,次大值,最后比较剩下值的和。
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + ;
struct node{
string name;
int id = ;
int sum = ;
int maxx = ;
int maxx2 = ;
};
node a[maxn];
bool cmp(const node &a, const node &b)
{
if(a.id != b.id) return a.id > b.id;
if(a.maxx != b.maxx) return a.maxx > b.maxx;
if(a.maxx2 != b.maxx2) return a.maxx2 > b.maxx2;
if(a.sum != b.sum) return a.sum > b.sum;
return a.name < b.name;
}
int v[];
int main()
{
std::ios::sync_with_stdio(false);
int n;
string s;
cin >> n;
for(int i = ;i < n;i++)
{
cin >> a[i].name >> s;
int cnt = ;
for(int j = ;j < s.size();j++)
{
if(s[j] == '') continue;
else if(s[j] == '') v[cnt++] = ;
else if(s[j] == 'A') v[cnt++] = ;
else if(s[j] == 'J') v[cnt++] = ;
else if(s[j] == 'Q') v[cnt++] = ;
else if(s[j] == 'K') v[cnt++] = ;
else v[cnt++] = s[j] - '';
}
sort(v, v + );
int vis[] = {};
for(int j= ;j < ;j++)
{
a[i].sum += v[j];
vis[v[j]]++;
}
if(v[] == && v[] == && v[] == && v[] == && v[] == ){
a[i].id = ;continue;
}
if(v[] == v[] + && v[] == v[] + && v[] == v[] - && v[] == v[] - ){
a[i].id = ;
a[i].maxx = v[];
continue;
}
int two = , three = ;
int t = , tt = , ttt;
for(int j = ;j <= ;j++)
{
if(vis[j] == ){
a[i].id = ;
a[i].maxx = j;
a[i].sum -= j * ;
break;
}
if(vis[j] == ) three ++, ttt = j ;
if(vis[j] == ){
two++;
if(!t) t = j;
else tt = j;
}
}
if(three == && two == )
{
a[i].id = ;
a[i].maxx = ttt;
a[i].maxx2 = t;
continue;
}
if(three == )
{
a[i].id = ;
a[i].maxx = ttt;
a[i].sum -= * ttt;
continue;
}
if(two == )
{
a[i].id = ;
a[i].maxx = max(t,tt);
a[i].maxx2 = min(t,tt);
a[i].sum -= (t + tt) * ;
}
if(two){
a[i].id = ;
a[i].maxx = t;
a[i].sum -= *t;
}
}
sort(a, a + n, cmp);
for(int i = ;i < n;i++)
{
cout << a[i].name << endl;
//cout << " " << a[i].id << " " << a[i].maxx << " " << a[i].maxx2 << " " << a[i].sum << endl;
}
return ;
}
最新文章
- viewgager
- PAT乙级 1032. 挖掘机技术哪家强(20)
- VS2015 ASP.NET5 Web项目结构浅析
- javascript中数组的concat()方法 - 数组连接
- Hbase Shell命令
- call()和apply()的区别
- C语言之指针1.1数组
- android design library提供的TabLayout的用法
- lua的前景??
- java 中缀转后缀(逆波兰)
- 开放源代码的微微信.NET 0.8 版公布了
- weblogic11g 配置数据源
- 基于layui和bootstrap搭建极简后台管理框架
- 那些年踩过的WebAPI的坑(一)
- 如何在Cocos2D 1.0 中掩饰一个精灵(一)
- R语言-图形辅助
- docker搭建nginx+springboot集群
- JavaScript的类型自动转换样例集合处
- MyBatis批量增删改查操作
- js-ES6学习笔记-module(3)