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. python学习笔记之数据类型、字符编码、文件处理

    1.数据类型 1.数字(int,float) 整形(int):定义 age=20  #本质age=int(20) 浮点类型:salary=3000.3 #本质salary=float(3000.3) ...

  2. 字典dict详解

    字典也是 Python 提供的一种常用的数据结构,它用于存放具有映射关系的数据. 比如有份成绩表数据,语文:79,数学:80,英语:92,这组数据看上去像两个列表,但这两个列表的元素之间有一定的关联关 ...

  3. springCloud的使用02-----服务消费者(rest+ribbon)

    1 将服务提供者做成集群模式 配置service-hi的端口为8762进行启动,配置service-hi的端口为8763进行启动, service-hi会在ecureka server上注册两个ser ...

  4. 60.Median of Two Sorted Arrays(两个排序数组的中位数)

    Level:   Hard 题目描述: There are two sorted arrays nums1 and nums2 of size m and n respectively. Find t ...

  5. 简述ArcGIS的空间连接(Spatial Join)与字段映射(Field Map)操作

    插个广告,制作ArcGIS的Tool工具学习下面的教程就对了:零基础学习Python制作ArcGIS自定义工具 牢骚一下 在使用ArcMap进行空间连接操作的时候,往往会有两种特殊需求,其一是连接重叠 ...

  6. 面试题:实现call、apply、bind

    面试题:实现call.apply.bind 实现bind module.exports = function(Tcontext, ...args) { let globalThis = typeof ...

  7. numpy 中的broadcast 机制

    https://www.cnblogs.com/jiaxin359/p/9021726.html

  8. 如何理解CPU上下文切换(二)

    如何理解CPU上下文切换(二) 1.引 你们好,可爱的小伙伴们.^_^ 多个进程竞争CPU就是一个经常被我们忽视的问题. 你们一定很好奇,进程在竞争CPU的时候并没有真正运行,为什么还会导致系统的负载 ...

  9. Python之 set的特点

    set的内部结构和dict很像,唯一区别是不存储value,因此,判断一个元素是否在set中速度很快. set存储的元素和dict的key类似,必须是不变对象,因此,任何可变对象是不能放入set中的. ...

  10. 74th Jupyter Notebook 插入图片的方法

    转载: https://account.cnblogs.com/signin?ReturnUrl=http%3A%2F%2Fhome.cnblogs.com%2Fu%2Ferdou%2F   插入本地 ...