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 模拟 + 思考的更多相关文章

  1. CF Soldier and Cards (模拟)

    Soldier and Cards time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  2. Codeforces 626B Cards(模拟+规律)

    B. Cards time limit per test:2 seconds memory limit per test:256 megabytes input:standard input outp ...

  3. Codeforces Round #304 (Div. 2) C. Soldier and Cards —— 模拟题,队列

    题目链接:http://codeforces.com/problemset/problem/546/C 题解: 用两个队列模拟过程就可以了. 特殊的地方是:1.如果等大,那么两张牌都丢弃 : 2.如果 ...

  4. 【HDOJ6666】Quailty and CCPC(模拟)

    题意:给出罚时现场赛的题数和罚时,问是否有在金牌线下取整被卡出,四舍五入卡入的队伍 n<=1e5 思路: #include<bits/stdc++.h> using namespac ...

  5. [CF546C] Soldier and Cards - 模拟

    两个人玩牌,首先两个人都拿出自己手牌的最上面的进行拼点,两张拼点牌将都给拼点赢得人,这两张牌放入手牌的顺序是:先放对方的牌再放自己的.若最后有一个人没有手牌了,那么他就输了,求输出拼点的次数和赢得人的 ...

  6. 多校训练赛2 ZCC loves cards

    ZCC loves cards Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) ...

  7. PAT/简单模拟习题集(二)

    B1018. 锤子剪刀布 (20) Discription: 大家应该都会玩"锤子剪刀布"的游戏:两人同时给出手势,胜负规则如图所示: 现给出两人的交锋记录,请统计双方的胜.平.负 ...

  8. LoadRunner 思考时间与事务响应时间的区别与关系

    LoadRunner 思考时间与事务响应时间的区别与关系   思考时间lr_think_time 就是一个事务要开始时思考的时间;比如 你要点击一个 登录按钮 我们都要点击这个按钮要先思考下 就是人为 ...

  9. CodeForces 471C MUH and House of Cards

    MUH and House of Cards Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & % ...

随机推荐

  1. C#分词算法

    本文用到的库下载:点此下载 词库下载:点此下载 将词库直接放到项目根目录 词库设置如下: 类库说明 词库查看程序:点此下载 可以在上面的程序中添加常用行业词库 还可以通过下面的类在程序中实现 完整的盘 ...

  2. Python-Redis的List操作

    Redis列表是简单的字符串列表,一个列表可以包含超过40亿个元素 lpush(name,values):在name对应的list中添加元素,每个新的元素都添加到列表的最左边 rpush(name, ...

  3. 1.JasperReports学习笔记1-了解JasperReports

    转自:http://www.blogjava.net/vjame/archive/2013/10/12/404908.html JasperReports是一个开源的java报表制作引擎,官网地址:h ...

  4. Spinner 通过XML形式绑定数据时 无法从String.xml中读取数组

    在android应用程序中,通过XML形式给Spinner绑定数据,如果把数组放在系统的string.xml文件里,那么就有可能在运行时无法找到,导致程序异常结束,解决方法是自建一个XML文件来存放数 ...

  5. Koa1 框架

    安装创建项目: 1.一定要全局安装(koa1.2和koa2都己经支持) npm install koa-generator -g 2.koa1 生成一个test项目,切到test目录并下载依赖 koa ...

  6. Centos 查看机器型号

    测试机器的硬件信息: 查看CPU信息(型号) # cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c 8 Intel(R) Xeon(R) CP ...

  7. 剑指offer(65):获取数据流中的中位数

    参考 https://blog.csdn.net/u011080472/article/details/51291089 题目描述 如何得到一个数据流中的中位数?如果从数据流中读出奇数个数值,那么中位 ...

  8. 7.SSRF漏洞绕过IP限制

    绕过SSRF过滤的几种方法 下文出现的192.168.0.1,10.0.0.1全部为服务器端的内网地址. 1.更改IP地址写法 一些开发者会通过对传过来的URL参数进行正则匹配的方式来过滤掉内网IP, ...

  9. 除了BAT,计算机、软件专业的毕业生还有别的好去处吗?

    "学技术的同学应该关注36氪.pingwest,极客公园这些圈子里很有影响力的科技媒体" 转载--除了BAT,计算机.软件专业的毕业生还有别的好去处吗? 又到校招季,985理工科的 ...

  10. 22. Generate Parentheses (recursion algorithm)

    Given n pairs of parentheses, write a function to generate all combinations of well-formed parenthes ...