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 ...
随机推荐
- 【CF633D】Fibonacci-ish
题目描述 小y最近迷上了fibonacci数列,他定义了一种数列叫类fibonacci数列: 1.这个数列包含至少\(2\)个元素 2.\(f_0\)和\(f_1\)是任意选取的 3.\(f_{n+2 ...
- MobaXterm之取消自动关闭连接 Network error :Connection timed out
连一会就出现连接重来的问题 配置如下.
- Android stadio 生成项目 Cannot find System Java Compiler. Ensure that you have installed a JDK (not just a JRE)
解决方法 File-->Project-->Structrue-->SDK Location-->JDK location Use embedded JDK 前面勾去掉,指定一 ...
- 【Vijos】lxhgww的奇思妙想(长链剖分)
题面 给定一棵树,每次询问一个点的\(k\)次祖先,强制在线. Vijos 题解 长链剖分. 链接暂时咕咕咕了. 现在可以戳链接看题解了 #include<iostream> #inclu ...
- mac上安装memcache
1. 安装 brew (http://brew.sh/) /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/H ...
- python列表转字符串
temp = "".join(sorted(arr[i])) arr[i] = temp
- Why I don't want use JPA anymore
转自:https://dev.to/alagrede/why-i-dont-want-use-jpa-anymore-fl Great words for what is considered by ...
- SpringBoot整合阿里Druid数据源及Spring-Data-Jpa
SpringBoot整合阿里Druid数据源及Spring-Data-Jpa https://mp.weixin.qq.com/s?__biz=MzU0MDEwMjgwNA==&mid=224 ...
- 【CF242E】Xor Segment
题目大意:给定一个长度为 N 的序列,支持两种询问,即:区间异或,区间求和. 题解:加深了对线段树的理解. 对于线段树维护的变量一定是易于 modify 的,对于查询的答案只需用维护的东西进行组合而成 ...
- java基本数据类型转换溢出问题
java的基本数据类型有(int.byte.double.float.char.boolean.long.short):这里介绍整型数据 示例1: public class H_Z01 { publi ...