ACM-ICPC 2018 南京赛区网络预赛 C GDY(模拟)
https://nanti.jisuanke.com/t/30992
题意
把m张牌(牌上数字范围是1-13)放到栈里
n个人,每个人首次从栈顶取5张牌,轮流取
取完牌后,第1个人出他手里最小的牌,
然后2-n个人轮流出牌,每次出牌的选择是:
(1)出比前一个人的牌大1的牌
(2)在前一个牌不是2的时候可以出2
(优先选择(1)出牌方式出牌)
如果第i个人没有能出的牌,他就“过”
如果第X个人出完牌后,走了一圈到了X,中间没一个人能出牌,那么从X开始所有人要从栈中取一张牌,接着,X出他手里最小的牌。
如果栈里没牌了,那么就跳过取牌的环节
谁先出完牌谁胜,剩下的人输出他的惩罚(惩罚是手里牌的值之和)
分析
根据题意模拟就好,比赛时来不及做呀,我太弱了
#include <bits/stdc++.h>
using namespace std;
int a[][],b[],c[],n,m,cnt,winner;
inline void get(int id){
if(cnt < m)a[id][b[cnt++]]++,c[id]++;
}
inline void decrease(int i,int j){
a[i][j]--,c[i]--;
if(!c[i])winner = i;
}
void print(){
for(int i = ;i < n;i++){
if(i == winner)puts("Winner");
else{
int sum = ;
for(int j = ;j <= ;j++)sum += j*a[i][j];
printf("%d\n",sum);
}
}
}
int main(){
int T;
scanf("%d",&T);
for(int t = ;t <= T;t++){
bool flag = false;
cnt = ,winner = -;
int id = ,p = ,now;
memset(a,,sizeof(a));
memset(b,,sizeof(b));
memset(c,,sizeof(c));
scanf("%d %d",&n,&m);
for(int i = ;i < m;i++)scanf("%d",&b[i]);
for(int i = ;i < n;i++)for(int j = ;j < ;j++)get(i);
while(winner == -){
if(id == p%n){
if(flag){
for(int i = id;i < n;i++)get(i);
for(int i = ;i < id;i++)get(i);
}
flag = true;
for(int i = ;i <= ;i++)
if(a[id][i]){
now = i;
decrease(id,now);
goto label;
}
for(int i = ;i <= ;i++)
if(a[id][i]){
now = i;
decrease(id,now);
goto label;
}
label:
p++;
}
else{
if(now == ){
if(a[p%n][]){
now = ;
id = p%n;
decrease(id,now);
}
else if(a[p%n][]){
now = ;
id = p%n;
decrease(id,now);
}
}
else if(now != ){
if(a[p%n][now+]){
now++;
id = p%n;
decrease(id,now);
}
else if(a[p%n][]){
now = ;
id = p%n;
decrease(id,now);
}
}
p++;
}
}
printf("Case #%d:\n",t);
print();
}
return ;
}
ACM-ICPC 2018 南京赛区网络预赛 C GDY(模拟)的更多相关文章
- ACM-ICPC 2018 南京赛区网络预赛 J.sum
A square-free integer is an integer which is indivisible by any square number except 11. For example ...
- ACM-ICPC 2018 南京赛区网络预赛 E题
ACM-ICPC 2018 南京赛区网络预赛 E题 题目链接: https://nanti.jisuanke.com/t/30994 Dlsj is competing in a contest wi ...
- ACM-ICPC 2018 南京赛区网络预赛B
题目链接:https://nanti.jisuanke.com/t/30991 Feeling hungry, a cute hamster decides to order some take-aw ...
- 计蒜客 30999.Sum-筛无平方因数的数 (ACM-ICPC 2018 南京赛区网络预赛 J)
J. Sum 26.87% 1000ms 512000K A square-free integer is an integer which is indivisible by any squar ...
- 计蒜客 30996.Lpl and Energy-saving Lamps-线段树(区间满足条件最靠左的值) (ACM-ICPC 2018 南京赛区网络预赛 G)
G. Lpl and Energy-saving Lamps 42.07% 1000ms 65536K During tea-drinking, princess, amongst other t ...
- 计蒜客 30990.An Olympian Math Problem-数学公式题 (ACM-ICPC 2018 南京赛区网络预赛 A)
A. An Olympian Math Problem 54.28% 1000ms 65536K Alice, a student of grade 66, is thinking about a ...
- ACM-ICPC 2018 南京赛区网络预赛 B. The writing on the wall
题目链接:https://nanti.jisuanke.com/t/30991 2000ms 262144K Feeling hungry, a cute hamster decides to o ...
- ACM-ICPC 2018 南京赛区网络预赛
轻轻松松也能拿到区域赛名额,CCPC真的好难 An Olympian Math Problem 问答 只看题面 54.76% 1000ms 65536K Alice, a student of g ...
- ACM-ICPC 2018 南京赛区网络预赛 L. Magical Girl Haze
262144K There are NN cities in the country, and MM directional roads from uu to v(1\le u, v\le n)v ...
随机推荐
- Tmutarakan Exams URAL - 1091(莫比乌斯函数 || 容斥)
题意: 求1 - s 中 找出k个数 使它们的gcd > 1 求这样的k个数的对数 解析: 从每个素数的倍数中取k个数 求方案数 然后素数组合,容斥一下重的 奇加偶减 莫比乌斯函数的直接套模 ...
- Chessboard POJ - 2446(最大流 || 匹配)
there is a pair of integers (x, y) in each line, which represents a hole in the y-th row, the x-th c ...
- 【XSY2718】gift 分数规划 网络流
题目描述 有\(n\)个物品,买第\(i\)个物品要花费\(a_i\)元.还有\(m\)对关系:同时买\(p_i,q_i\)两个物品会获得\(b_i\)点收益. 设收益为\(B\),花费为\(A\), ...
- android 通过修改图片像素实现CircleImageView
CircleImageView实现方法有很多种,各有优缺点,因此需要按照不同的场景使用.我们今天使用修改图片像素的方法实现CircleImageView,主要知识点无非是勾股定理和点到圆形的距离. 素 ...
- python3 函数function
def function(arg): pass 变量: 由字母.数字和下划线构成,不能以数字开头,不能任意特殊字符 变量定义规范,使用驼峰式或者下划线式格式 变量定义尽量简明,易懂,方便使用者应用 作 ...
- 【BZOJ2823】[AHOI2012]信号塔(最小圆覆盖)
[BZOJ2823][AHOI2012]信号塔(最小圆覆盖) 题面 BZOJ 洛谷 相同的题: BZOJ1 BZOJ2 洛谷 题解 模板题... #include<iostream> #i ...
- Codeforces | CF1000B 【Light It Up】
蒟蒻第二篇题解... 比赛的时候写这道题MLE了qwq..根据CF的赛制我也没敢再交第二次.. 简单讲一下思路好了(假装是dalao)..根据题意要加一个或者不加新的点..如果加一个新的点意味着从这个 ...
- [luogu3878][TJOI2010]分金币【模拟退火】
题目描述 现在有n枚金币,它们可能会有不同的价值,现在要把它们分成两部分,要求这两部分金币数目之差不超过1,问这样分成的两部分金币的价值之差最小是多少? 分析 根据模拟退火的基本套路,先随机分两堆金币 ...
- luogu3278/bzoj3323 多项式的运算 (splay)
mulx的操作,其实就是给r+1的系数+=r的系数,然后删掉r,把l~r-1向右移一位,再插一个0到原来的位置 splay维护区间加和区间乘就好了 (一定要注意做事的顺序,一件事都做完了再去做别的,否 ...
- 使用Docker for Windows初体验
https://www.baidu.com/link?url=61Kwadwh6h__2Vmjf7lAKVo1RjhsULAqERcMXYnYzkLKrRVpygwBJVnjultH8zbq& ...