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 & % ...
随机推荐
- 升级MySQL 5.7版本遇到的一些小问题(转)
在5.6版本服务器做备份 /usr/local/mysql/bin/mysqldump -S /tmp/mysql3306.sock -A -p --set-gtid-purged=OFF > ...
- 问题11:如何进行反向迭代 & 如何实现反向迭代
# 有关列表问题,参考:Python:列表list 案例: 需求:实现一个连续浮点数发生器FloatRange(和range类似),根据给定范围(start,end)和步进值(step),产生一系列连 ...
- vue.js 使用高德地图
1.获取key值 注册成为高德开发者需要分三步: 第一步,注册高德开发者: 第二步,去控制台创建应用: 第三步,获取Key 2.修改配置文件 webpack.base.conf.js externa ...
- Flask06 地址约定、利用falsk提供的方法渲染模板
1 访问地址约定 在访问路径的末尾是否需要加 / -> 可以加,也可以不加 前端的访问路径必须和后端的路径完全匹配才能够访问成功,如果我们在后台的路径都是以 / 结尾,但是我们的访问路径是没有以 ...
- [MySQL] Data too long for column 'title' at row 1
李刚轻量级JavaEE第六章的坑..艹李刚自己有没试过这些代码的啊,6.4这一份HqlQuery.java里需要的表,根本就跟他提供的sql脚本对不上啊..坑爹啊,而且字符编码集也有问题. 出现这个原 ...
- 6.wireshark使用全解
开始之前先推荐一个wireshark视频: http://www.shiyanbar.com/course-video/watchVideo/cid/419/vid/2001 页面功能简介 1.主界面 ...
- doxygen+ graphviz 开源工具生成源码调用树的wiki
当拿到一含有大量代码的工程怎么看?!这时一个好的代码分析工具非常有用,网上有很多开源工具,但资料都参差不齐,偶然发现doxygen+ graphviz这两工具非常棒,使用工具直接生成函数调用链图,帮助 ...
- <转>哥舒意:关于米奇的三个真相 (米奇·阿尔博姆)
http://book.douban.com/review/6436827/ <时光守护者>的故事也不算复杂,虽然有三条线同时进行,但是三条线的情节都条理分明,而且这次他使用了类似于奇 ...
- 【mysql模糊查询的几种方式】
select * from activyty_code where acname like '%yj%' 1:%:表示任意0个或多个字符.可匹配任意类型和长度的字符,有些情况下若是中文,请使用两个百分 ...
- js中top.location.href、parent.location.href用法
window.location.href.location.href是本页面跳转 parent.location.href是上一层页面跳转 top.location.href是最外层的页面跳转 举例说 ...