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 & % ...
随机推荐
- debian服务查询
1.查询 用root身份执行service --status-all查看所有服务的状态 "+" started "-" stopped "?" ...
- Python-编写一个mysql注入漏洞检测工具
判断mysql网站是否存在注入漏洞的几个方法: 注入点后加上一个单引号会报错 and 1=1返回正常页面,and 1=2返回的页面不同于正常页面 and sleep(3) 网页会等待3秒左右 根据返回 ...
- 【原】spring jar 下载
作者:david_zhang@sh [转载时请以超链接形式标明文章] 链接:http://www.cnblogs.com/david-zhang-index/p/8098965.html 1.进入官网 ...
- LAMP 1.7Apache用户认证
假如我们要在www.aaa.com/的 abc/目录下放一些文件,只想让自己访问,做一个用户认证.输入正确的用户和密码才能访问 cd /data/www mkdir abc cd abc cp /et ...
- SQL标量值函数:返回汉字拼音首拼
今天遇到一个需求,客户要求在系统客户端选择客户的时候,可以用拼音首拼去快速过滤选择,此时我们在客户表里面加多一个拼音首拼字段CustPY来记录,字段加好了,我们要把所有客户名称的拼音简拼都更新到Cus ...
- C# 写 LeetCode easy #28 Implement strStr()
28.Implement strStr() Implement strStr(). Return the index of the first occurrence of needle in hays ...
- [CentOS7] 使用磁盘分割建立swap
声明:本文主要总结自:鸟哥的Linux私房菜-第七章.Linux 磁碟與檔案系統管理,如有侵权,请通知博主 通过 vim /etc/fstab 使该新建的swap分区每次开机都自己挂载 至此,已经完成 ...
- 洛谷P3092 [USACO13NOV]没有找零No Change
P3092 [USACO13NOV]没有找零No Change 题目描述 Farmer John is at the market to purchase supplies for his farm. ...
- 字符串游戏(strgame)——博弈
题目 [题目描述] pure 和 dirty 决定玩 $T$ 局游戏.对于每一局游戏,有 $n$ 个字符串,并且每一局游戏由 $K$ 轮组成.具体规则如下:在每一轮游戏中,最开始有一个空串,两者轮流向 ...
- postgres_fdw
create extension postgres_fdw; --创建扩展 create server db0 foreign data wrapper postgres_fdw OPTIONS (h ...