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 & % ...
随机推荐
- ECMAScript中面向对象的程序设计思想总结
<JavaScript高级程序设计>Chapter6笔记 1.ECMAScript内部值属性:数据属性和访问器属性 1)数据属性 数据属性的4个特性: configurable:表示能否通 ...
- 【转】 Pro Android学习笔记(五四):调试和分析(2):View层次结构
目录(?)[-] 帮助性能分析 帮助精简UI设计 对于模拟器上的应用(非真实设备),可以查看Hierarchy View,如下图: 帮助性能分析 当我们选择某个view时,我们可以看到measurin ...
- js右击事件
先贴代码: <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF ...
- 使用jquery扩展表格行合并方法探究
1.前言 最近项目中用到一个表格中对于相同内容的数据进行行合并的需求,本来想从网上找个现成的,省的自己再造轮子.于是就开始谷歌了...不过在搜索的过程中,发现找到的工具类很多都有一个前提,就是该表格中 ...
- Ajax前端调后台方法
后台对当前页面类进行注册 Ajax.Utility.RegisterTypeForAjax(typeof(Login));//Login 当前类名 在方法上面加 [Ajax.AjaxMethod(Aj ...
- [java] bug经验 Unable to locate Spring NamespaceHandler for XML schema namespace解决办法
报错关键字: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration probl ...
- [Uva12260]Free Goodies(dp+贪心)
解题关键:先对p进行排序,消除p的影响,然后对w进行01背包即可.注意p对w的约束.j<=(cur+1)/2 #include<cstdio> #include<cstring ...
- 树莓派 Learning 002 装机后的必要操作 --- 01 解决上网问题
树莓派 装机后的必要操作 - 解决上网问题 我的树莓派型号:Raspberry Pi 2 Model B V1.1 装机系统:NOOBS v1.9.2 树莓派 装机后的必要操作 解决上网问题 解决上网 ...
- Windows使用Github
首先,你需要执行下面两条命令,作为 git 的基础配置,作用是告诉 git 你是谁,你输入的信息将出现在你创建的提交中. git config --global user.name "你的名 ...
- htmlparser API
htmlparser所有的filter htmlparser所有的Tags htmlparser API: http://htmlparser.sourceforge.net/javadoc/inde ...