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(模拟)的更多相关文章

  1. ACM-ICPC 2018 南京赛区网络预赛 J.sum

    A square-free integer is an integer which is indivisible by any square number except 11. For example ...

  2. ACM-ICPC 2018 南京赛区网络预赛 E题

    ACM-ICPC 2018 南京赛区网络预赛 E题 题目链接: https://nanti.jisuanke.com/t/30994 Dlsj is competing in a contest wi ...

  3. ACM-ICPC 2018 南京赛区网络预赛B

    题目链接:https://nanti.jisuanke.com/t/30991 Feeling hungry, a cute hamster decides to order some take-aw ...

  4. 计蒜客 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 ...

  5. 计蒜客 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 ...

  6. 计蒜客 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 ...

  7. 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 ...

  8. ACM-ICPC 2018 南京赛区网络预赛

    轻轻松松也能拿到区域赛名额,CCPC真的好难 An Olympian Math Problem 问答 只看题面 54.76% 1000ms 65536K   Alice, a student of g ...

  9. 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 ...

随机推荐

  1. python学习日记(join,range)

    join方法 join方法用于将序列里的字符串以指定的字符串连接成一个新的字符串 s = 'fasfw123' s1 = '-'.join(s) print(s1) str = '&ooooo ...

  2. hz2016的noip模拟赛(d1 + d2)

    QAQ怕不是真的凉凉 d1 205 + d2 170 = 375 感觉难度和noip差不多 那么这可是有够凉的 官方题解 D1 D2 D1 T1 某地的ENLIGHTENED总部总部有N个Agent, ...

  3. 用决策树(CART)解决iris分类问题

    首先先看Iris数据集 Sepal.Length--花萼长度 Sepal.Width--花萼宽度 Petal.Length--花瓣长度 Petal.Width--花瓣宽度 通过上述4中属性可以预测花卉 ...

  4. 【CF809C】Find a car(动态规划)

    [CF809C]Find a car(动态规划) 题面 洛谷 CF 有一个无穷大的矩阵,第\(i\)行第\(j\)列的数是\((i-1)xor(j-1)+1\),\(q\)次询问,每次询问一个矩形内数 ...

  5. 【BZOJ5339】[TJOI2018]教科书般的亵渎(斯特林数)

    [BZOJ5339][TJOI2018]教科书般的亵渎(斯特林数) 题面 BZOJ 洛谷 题解 显然交亵渎的次数是\(m+1\). 那么这题的本质就是让你求\(\sum_{i=1}^n i^{m+1} ...

  6. java ee wildfly 批处理 job 工作

    配置批处理job,同时启动两个并行任务processData,syncTableTask,执行往后执行第三个任务job:playDurationTask. xml配置如下: <job id=&q ...

  7. Transactional ejb 事务陷阱

    对应ejb,默认是对整个类使用事务.所以所有方法都开启事务. 而对于用TransactionAttribute注释来引用容器管理的事务,只能在第一级的方法中使用.对应类中的方法再调用其它类中方法,注释 ...

  8. 洛谷P3242 接水果

    关于矩形与点其实有两种关系. 一种是每个矩形包含多少点.一种是每个点被多少矩形包含. 解:因为可以离线所以直接套整体二分.关键是考虑如何能够被覆盖. 我一开始都是想的树上操作...其实是转化成DFS序 ...

  9. 收藏:win32 控件之 sysLink控件(超链接)

    来源:https://blog.csdn.net/dai_jing/article/details/8683487 手动创建syslink(msdn): CreateWindowEx(, WC_LIN ...

  10. RGBColorspace 与 GRAYColorspace 图片混合后,生成的视频有点问题

    最近有一个用户遇到一个情况: 有3张图片,其中前两张是 RGBColorspace,最后一张是 GrayColorspace: 生成的视频,在显示最后一张图片的时候,明显出现奇怪的色彩区域,看下图: ...