A -- A. Quailty and Playing Cards 模拟 + 思考
http://www.ifrog.cc/acm/problem/1036?contest=1005&no=0
分类,考虑Q神出的是第一张或者是第二张,然后对手出那些牌来应付。
Q神出第一张和第二张的情况是分开的,应该取两者的最大值。(因为要取最优情况)
而Q神出第一张的时候,对手出任意一张,是取min,保证对手出牌最优
注意这里花色是没用的。
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL; #include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
int book[];
struct node {
int num, val;
} a[];
int add(int val) {
if (val != ) return val;
else return ;
}
int judge(node a, node b, int who) {
if (a.num > b.num) {
return add(a.num);
} else if (a.num == b.num) {
if (who == ) {
return add(a.num);
} else return -add(b.num);
} else {
return -add(b.num);
}
}
void work() {
for (int i = ; i <= ; ++i) {
char str[];
scanf("%s", str + );
a[i].num = book[str[]];
a[i].val = book[str[]];
}
// for (int i = 1; i <= 4; ++i) {
// cout << a[i].num << " " << a[i].val << endl;
// }
// cout <<"***" << endl;
int ans = inf;
int t = ;
if (judge(a[], a[], ) > ) {
t += judge(a[], a[], );
t += judge(a[], a[], );
} else {
t += judge(a[], a[], );
t += judge(a[], a[], );
}
ans = min(ans, t);
t = ;
if (judge(a[], a[], ) > ) {
t += judge(a[], a[], );
t += judge(a[], a[], );
} else {
t += judge(a[], a[], );
t += judge(a[], a[], );
}
ans = min(ans, t); t = ;
int ans2 = inf;
if (judge(a[], a[], ) > ) {
t += judge(a[], a[], );
t += judge(a[], a[], );
} else {
t += judge(a[], a[], );
t += judge(a[], a[], );
}
ans2 = min(ans2, t);
t = ;
if (judge(a[], a[], ) > ) {
t += judge(a[], a[], );
t += judge(a[], a[], );
} else {
t += judge(a[], a[], );
t += judge(a[], a[], );
} ans2 = min(ans2, t); // cout << ans << " " << ans2 << endl; ans = max(ans, ans2);
cout << ans << endl;
}
int main() {
#ifdef local
freopen("data.txt","r",stdin);
#endif
book['A'] = ;
book['K'] = ;
book['Q'] = ;
book['J'] = ;
book['T'] = ;
for (int i = ''; i <= ''; ++i) {
book[i] = i - '';
}
book['H'] = ;
book['S'] = ;
book['C'] = ;
book['D'] = ;
int t;
scanf("%d", &t);
while(t--) {
work();
}
return ;
}
A -- A. Quailty and Playing Cards 模拟 + 思考的更多相关文章
- CF Soldier and Cards (模拟)
Soldier and Cards time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- Codeforces 626B Cards(模拟+规律)
B. Cards time limit per test:2 seconds memory limit per test:256 megabytes input:standard input outp ...
- Codeforces Round #304 (Div. 2) C. Soldier and Cards —— 模拟题,队列
题目链接:http://codeforces.com/problemset/problem/546/C 题解: 用两个队列模拟过程就可以了. 特殊的地方是:1.如果等大,那么两张牌都丢弃 : 2.如果 ...
- 【HDOJ6666】Quailty and CCPC(模拟)
题意:给出罚时现场赛的题数和罚时,问是否有在金牌线下取整被卡出,四舍五入卡入的队伍 n<=1e5 思路: #include<bits/stdc++.h> using namespac ...
- [CF546C] Soldier and Cards - 模拟
两个人玩牌,首先两个人都拿出自己手牌的最上面的进行拼点,两张拼点牌将都给拼点赢得人,这两张牌放入手牌的顺序是:先放对方的牌再放自己的.若最后有一个人没有手牌了,那么他就输了,求输出拼点的次数和赢得人的 ...
- 多校训练赛2 ZCC loves cards
ZCC loves cards Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) ...
- PAT/简单模拟习题集(二)
B1018. 锤子剪刀布 (20) Discription: 大家应该都会玩"锤子剪刀布"的游戏:两人同时给出手势,胜负规则如图所示: 现给出两人的交锋记录,请统计双方的胜.平.负 ...
- LoadRunner 思考时间与事务响应时间的区别与关系
LoadRunner 思考时间与事务响应时间的区别与关系 思考时间lr_think_time 就是一个事务要开始时思考的时间;比如 你要点击一个 登录按钮 我们都要点击这个按钮要先思考下 就是人为 ...
- CodeForces 471C MUH and House of Cards
MUH and House of Cards Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & % ...
随机推荐
- Poj 2602 Superlong sums(大数相加)
一.Description The creators of a new programming language D++ have found out that whatever limit for ...
- 【转】 Pro Android学习笔记(六九):HTTP服务(3):HTTP POST MultiPart
目录(?)[-] 建立测试环境 开发环境导入第三方JAR HTTP Post Multipart小例子 HTTP POST不仅可以通过键值对传递参数,还可以携带更为复杂的参数,例如文件.HTTP Po ...
- web攻击之八:溢出攻击(nginx服务器防sql注入/溢出攻击/spam及禁User-agents)
一.什么是溢出攻击 首先, 溢出,通俗的讲就是意外数据的重新写入,就像装满了水的水桶,继续装水就会溢出,而溢出攻击就是,攻击者可以控制溢出的代码,如果程序的对象是内核级别的,如dll.sys文件等,就 ...
- AI:AI
ylbtech-AI:AI 人工智能(Artificial Intelligence),英文缩写为AI.它是研究.开发用于模拟.延伸和扩展人的智能的理论.方法.技术及应用系统的一门新的技术科学. 人工 ...
- ceph学习之CRUSH
CRUSH的全称是Controlled Replication Under Scalable Hashing,是ceph数据存储的分布式选择算法,也是ceph存储引擎的核心.在之前的博客里介绍过,ce ...
- linux命令-tar工具详解
把文件和目录打成一个包 文件打包 [root@wangshaojun ~]# tar -cvf 1.tar 1.txt 123 234 ///-c创建 -v可视化 -f file放最后面1.txt12 ...
- Windchill 查询功能
一.使用SearchCondition 查询语句中用容器中的containerReference.key.id名称来代替数据库中的字段idA3containerReference /** * ...
- 太有用了,所以转:Delphi下16进制位图数据转位图
如果我们在Form中拖入一个Image控件,并设置好picture后,Alt+F12就可以看到Form的源代码中已经将图片转成了16进制字符串,如下: object Image1: TImage Le ...
- Ubuntu使用crontab 使用举例
除了这些固定值外,还可以配合星号(*),逗号(,),和斜线(/)来表示一些其他的含义: 星号 表示任意值,比如在小时部分填写 * 代表任意小时(每小时) 逗号 ...
- uWSGI + Nginx + Django 部署
1. uWSGI 服务器 Django 默认使用 WSGI(Python Web Server Gateway ) 作为 Web 服务器,一般仅用来作为测试使用,实际生产环境而是使用 uWSGI 和 ...