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 ;
}

最新文章

  1. viewgager
  2. PAT乙级 1032. 挖掘机技术哪家强(20)
  3. VS2015 ASP.NET5 Web项目结构浅析
  4. javascript中数组的concat()方法 - 数组连接
  5. Hbase Shell命令
  6. call()和apply()的区别
  7. C语言之指针1.1数组
  8. android design library提供的TabLayout的用法
  9. lua的前景??
  10. java 中缀转后缀(逆波兰)
  11. 开放源代码的微微信.NET 0.8 版公布了
  12. weblogic11g 配置数据源
  13. 基于layui和bootstrap搭建极简后台管理框架
  14. 那些年踩过的WebAPI的坑(一)
  15. 如何在Cocos2D 1.0 中掩饰一个精灵(一)
  16. R语言-图形辅助
  17. docker搭建nginx+springboot集群
  18. JavaScript的类型自动转换样例集合处
  19. MyBatis批量增删改查操作
  20. js-ES6学习笔记-module(3)

热门文章

  1. Java并发:搞定线程池(上)
  2. zabbix真的很简单 (安装篇)
  3. 指针的value
  4. 使用UI Automation实现自动化测试--5-7
  5. 解决&amp;#65279产生的空白行
  6. Base64加密工具
  7. NOIP2015D1T2 信息传递
  8. web编程非常实用的在线工具大全---转载
  9. Java jvisualvm简要说明(转)
  10. 21.Semaphore信号量