The Preliminary Contest for ICPC Asia Shenyang 2019 H
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的更多相关文章
- The Preliminary Contest for ICPC Asia Shenyang 2019 H. Texas hold'em Poker
题目链接:https://nanti.jisuanke.com/t/41408 题目意思很简单,就是个模拟过程. #include <iostream> #include <cstr ...
- The Preliminary Contest for ICPC Asia Shenyang 2019
传送门 B. Dudu's maze 题意: 是什么鬼东西???我读题可以读半小时QAQ 给出一张无向图,一个人在里面收集糖果,每个点都有一个糖果,特殊点除外.当他第一次进入特殊点时,会随机往一条边走 ...
- The Preliminary Contest for ICPC Asia Shenyang 2019 F. Honk's pool
题目链接:https://nanti.jisuanke.com/t/41406 思路:如果k的天数足够大,那么所有水池一定会趋于两种情况: ① 所有水池都是一样的水位,即平均水位 ② 最高水位的水池和 ...
- 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 ...
- 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]也不需要更新.如果不整取的话,后 ...
- The Preliminary Contest for ICPC Asia Shenyang 2019 D. Fish eating fruit(树形dp)
题意:求一棵树上所有路径和模3分别为0 1 2 的权值的和 思路:树形dp 增加一个记录儿子节点满足条件的个数的数组 不要放在一起dp不然答案跟新会有问题 #include <bits/stdc ...
- The Preliminary Contest for ICPC Asia Nanjing 2019 H. Holy Grail
题目链接:https://nanti.jisuanke.com/t/41305 题目说的很明白...只需要反向跑spfa然后输入-dis,然后添-dis的一条边就好了... #include < ...
- 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/ ...
- The Preliminary Contest for ICPC Asia Nanjing 2019/2019南京网络赛——题解
(施工中……已更新DF) 比赛传送门:https://www.jisuanke.com/contest/3004 D. Robots(期望dp) 题意 给一个DAG,保证入度为$0$的点只有$1$,出 ...
随机推荐
- 如何为元组中的每个元素命名,提高程序可读性---Python数据结构与算法相关问题与解决技巧
实际案例: 学生信息系统中,数据为固定格式:(名字,年龄,性别,邮箱) ,通常使用元组来存储 使用优点: 使用元组最大的优点在于节省空间,存储相同的数据,使用元组比使用字典,空间小很多 使用缺点: 访 ...
- Maven 上传文件 Error creating bean with name 'multipartResolver':
<!--配置MultipartResolver 处理文件上传--><bean id="multipartResolver" class="org.spr ...
- str方法
'capitalize', 'casefold', 'center', 'count', 'encode', 'endswith', 'expandtabs', 'find', 'format', ' ...
- Netty 如何实现心跳机制与断线重连?
作者:sprinkle_liz www.jianshu.com/p/1a28e48edd92 心跳机制 何为心跳 所谓心跳, 即在 TCP 长连接中, 客户端和服务器之间定期发送的一种特殊的数据包, ...
- k8s 组件介绍-kube-controller-manager
1. Controller Manager简介 Controller Manager作为集群内部的管理控制中心,负责集群内的Node.Pod副本.服务端点(Endpoint).命名空间(Namespa ...
- go递归遍历文件目录
package main import ( "fmt" "io/ioutil" "log" ) //文件目录树形结构节点 type dirT ...
- SpringMVC学习(2):经典的HelloWorld实现
前一篇简单介绍了Spring MVC的一些知识,下面就要开始学习如何把Spring MVC运用到具体的项目中去. 首先还是从一个简单的Hello World项目说起: 我机器的开发环境为: Ubunt ...
- document.location window.location
document.location 和 window.location 取url的值的时候可以通用,但是 document是window的属性,所以不能直接用document.location =ur ...
- jq轮播图实现
html基本框架如下: <div class="out"> <ul class="img"> <li><a href= ...
- REST接口设计
REST接口设计 为什么要有REST 在传统上,软件和网络是两个不同的领域,很少有交集:软件开发主要针对单机环境,网络则主要研究系统之间的通信.互联网的兴起,使得这两个领域开始融合,现在我们必须考虑, ...