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

The Preliminary Contest for ICPC Asia Shenyang 2019 H的更多相关文章

  1. The Preliminary Contest for ICPC Asia Shenyang 2019 H. Texas hold'em Poker

    题目链接:https://nanti.jisuanke.com/t/41408 题目意思很简单,就是个模拟过程. #include <iostream> #include <cstr ...

  2. The Preliminary Contest for ICPC Asia Shenyang 2019

    传送门 B. Dudu's maze 题意: 是什么鬼东西???我读题可以读半小时QAQ 给出一张无向图,一个人在里面收集糖果,每个点都有一个糖果,特殊点除外.当他第一次进入特殊点时,会随机往一条边走 ...

  3. The Preliminary Contest for ICPC Asia Shenyang 2019 F. Honk's pool

    题目链接:https://nanti.jisuanke.com/t/41406 思路:如果k的天数足够大,那么所有水池一定会趋于两种情况: ① 所有水池都是一样的水位,即平均水位 ② 最高水位的水池和 ...

  4. The Preliminary Contest for ICPC Asia Shenyang 2019 C. Dawn-K's water

    题目:https://nanti.jisuanke.com/t/41401思路:完全背包 #include<bits/stdc++.h> using namespace std; int ...

  5. The Preliminary Contest for ICPC Asia Shenyang 2019 C Dawn-K's water (完全背包)

    完全背包为什么要取到M,可以取到2*M嘛,这题需要整取,对于不能整取的背包容量,dp[k]=INF,以及dp[j-water[i].weight]=INF时,dp[j]也不需要更新.如果不整取的话,后 ...

  6. The Preliminary Contest for ICPC Asia Shenyang 2019 D. Fish eating fruit(树形dp)

    题意:求一棵树上所有路径和模3分别为0 1 2 的权值的和 思路:树形dp 增加一个记录儿子节点满足条件的个数的数组 不要放在一起dp不然答案跟新会有问题 #include <bits/stdc ...

  7. The Preliminary Contest for ICPC Asia Nanjing 2019 H. Holy Grail

    题目链接:https://nanti.jisuanke.com/t/41305 题目说的很明白...只需要反向跑spfa然后输入-dis,然后添-dis的一条边就好了... #include < ...

  8. The Preliminary Contest for ICPC Asia Shanghai 2019 C Triple(FFT+暴力)

    The Preliminary Contest for ICPC Asia Shanghai 2019 C Triple(FFT+暴力) 传送门:https://nanti.jisuanke.com/ ...

  9. The Preliminary Contest for ICPC Asia Nanjing 2019/2019南京网络赛——题解

    (施工中……已更新DF) 比赛传送门:https://www.jisuanke.com/contest/3004 D. Robots(期望dp) 题意 给一个DAG,保证入度为$0$的点只有$1$,出 ...

随机推荐

  1. POJ 1860 Currency Exchange (Bellman-Ford)

    题目链接:POJ 1860 Description Several currency exchange points are working in our city. Let us suppose t ...

  2. docker调用yum时“"/usr/libexec/urlgrabber-ext-down" is not installed”

    原因: 1 docker镜像为高版本的fedora30:latest镜像,yum本身已被dnf替代,但部分功能仍不完整: 如:yum-builddep SPECS/xxx.spec 解决办法: 1 安 ...

  3. C++中类的静态成员变量

    1,成员变量的回顾: 1,通过对象名能够访问 public 成员变量: 2,每个对象的成员变量都是专属的: 3,成员变量不能在对象之间共享: 1,在做程序设计中,成员变量一般是私有的.至少不是公有的: ...

  4. [fw]awk求和

    suse11:~ # cat tmp.lst 4096 4 4096 4 4096 2 4096 4 8192 1 8192 4 8192 4 8192 4 8192 4 8192 4 8192 4 ...

  5. UVA - 11624 J - Fire! (BFS)

    题目传送门 J - Fire! Joe works in a maze. Unfortunately, portions of the maze have caught on fire, and the ...

  6. MySQL 基础 20191025

    1.MySQL(绿色软件)的安装后: (老师课件中的) 要设置字符集不然会报 1344 错误码,有两种: 为上面的还有一种为: set names 'utf8'; 2.MySQL管理 创建数据库 CR ...

  7. 【记录】logstash 命令解释

    输入./bin/logstash --help 查看对应解释如下 -f #意即文件,运行指定文件 #logstash 会自动读取 /etc/logstash.d/ 目录下所有 *.conf的文本文件, ...

  8. webshell yar

    webshell D盾 http://www.d99net.net/

  9. Bootstrap 网页实例

    代码: <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <met ...

  10. vue.config.js配置前端代理

    // vue.config.js 配置说明 //官方vue.config.js 参考文档 https://cli.vuejs.org/zh/config/#css-loaderoptions // 这 ...