Codeforces 401B Sereja and Contests【水题】
来源:互联网 发布:基础软件服务经营范围 编辑:程序博客网 时间:2024/06/07 22:55
题目大意:
已知有Div.1,和Div.2区分度的比赛,如果div1和div2比赛同时在一轮比赛中出现,div1的比赛编号保证比div2的编号大1.
一共有X编号,其中有K个已知参加了的比赛,其中K行如果是:
1 num1,num2,就表示这一场比赛div1div2是同时都有的,而且主人公只能参加div2.
2 num1,表示这一场比赛只有div2。
没有出现过的编号就是不知道的比赛,主人公想知道,他最少错过了多少场div2的比赛,最多错过了多少场div2的比赛。
思路:
1、很明显,最多错过的场数,就是从1-x-1中没有出现过的编号。
2、最少错过的场数,如果有连着两个编号都没有出现过,那么此时将这两个编号弄成一轮比赛(div1,div2同时在一轮中)即可。
Ac代码:
#include<stdio.h>#include<string.h>using namespace std;int vis[4500];int main(){ int x,k; while(~scanf("%d%d",&x,&k)) { memset(vis,0,sizeof(vis)); for(int i=0;i<k;i++) { int tmp; scanf("%d",&tmp); if(tmp==2) { int y; scanf("%d",&y); vis[y]=1; } else { int y,yy; scanf("%d%d",&y,&yy); vis[y]=1; vis[yy]=1; } } int minn=0; int maxn=0; for(int i=1;i<x;i++) { if(vis[i]==0)maxn++; } minn=maxn; for(int i=1;i<x;i++) { if(vis[i]==0&&vis[i+1]==0&&i+1<x) { vis[i]=1; vis[i+1]=1; minn--; } } printf("%d %d\n",minn,maxn); }}
0 0
- Codeforces 401B Sereja and Contests【水题】
- codeforces 401B - Sereja and Contests
- Codeforces 401B Sereja and Contests(DP)
- CodeForces 401B Sereja and Contests
- Codeforces 401B Sereja and Contests(水题)
- codeforces B. Sereja and Contests
- B. Sereja and Contests
- B. Sereja and Contests
- code forces 401B Sereja and Contests
- CF 401B Sereja and Contests
- Codeforces Round #235 (Div. 2)B. Sereja and Contests
- (CF)B. Sereja and Contests
- codeforces#235_div2_B Sereja and Contests
- Codeforces 381B Sereja and Stairs(水题)
- Codeforces 368B:Sereja and Suffixes(水题)
- Codeforces 426 B Sereja and Mirroring【暴力枚举+模拟】水题
- codeforces 315 B.Sereja and Array
- CodeForces 315B Sereja and Array
- html提交跳出框架页面
- <poj-2632>Crashing Robots
- html5 net XMLHttpRequest
- 并查集系列(一)——Social network connectivity
- Linux网络通信 -- TCP/IP协议
- Codeforces 401B Sereja and Contests【水题】
- LeetCode 第46,47题(Permutations)Java
- C语言编程注意事项
- [模板]康拓展开和他的逆运算
- Pillow学习之Image类(一)
- [Usaco06Dec] Cow Picnic
- signals linux
- hdu 5952 Counting Cliques(最大团思想+dfs)
- 线段树