Codeforces Round #235 (Div. 2)B. Sereja and Contests
来源:互联网 发布:js屏蔽查看网页源代码 编辑:程序博客网 时间:2024/05/22 10:57
Sereja is a coder and he likes to take part in Codesorfes rounds. However, Uzhland doesn't have good internet connection, so Sereja sometimes skips rounds.
Codesorfes has rounds of two types: Div1 (for advanced coders) and Div2 (for beginner coders). Two rounds, Div1 and Div2, can go simultaneously, (Div1 round cannot be held without Div2) in all other cases the rounds don't overlap in time. Each round has a unique identifier — a positive integer. The rounds are sequentially (without gaps) numbered with identifiers by the starting time of the round. The identifiers of rounds that are run simultaneously are different by one, also the identifier of the Div1 round is always greater.
Sereja is a beginner coder, so he can take part only in rounds of Div2 type. At the moment he is taking part in a Div2 round, its identifier equals to x. Sereja remembers very well that he has taken part in exactly k rounds before this round. Also, he remembers all identifiers of the rounds he has taken part in and all identifiers of the rounds that went simultaneously with them. Sereja doesn't remember anything about the rounds he missed.
Sereja is wondering: what minimum and what maximum number of Div2 rounds could he have missed? Help him find these two numbers.
The first line contains two integers: x (1 ≤ x ≤ 4000) — the round Sereja is taking part in today, and k (0 ≤ k < 4000) — the number of rounds he took part in.
Next k lines contain the descriptions of the rounds that Sereja took part in before. If Sereja took part in one of two simultaneous rounds, the corresponding line looks like: "1 num2 num1" (where num2 is the identifier of this Div2 round, num1 is the identifier of the Div1round). It is guaranteed that num1 - num2 = 1. If Sereja took part in a usual Div2 round, then the corresponding line looks like: "2num" (where num is the identifier of this Div2 round). It is guaranteed that the identifiers of all given rounds are less than x.
Print in a single line two integers — the minimum and the maximum number of rounds that Sereja could have missed.
3 22 12 2
0 0
9 31 2 32 81 4 5
2 3
10 0
5 9
In the second sample we have unused identifiers of rounds 1, 6, 7. The minimum number of rounds Sereja could have missed equals to 2. In this case, the round with the identifier 1 will be a usual Div2 round and the round with identifier 6 will be synchronous with the Div1round.
The maximum number of rounds equals 3. In this case all unused identifiers belong to usual Div2 rounds.
感觉挺简单的吧,题意是正在做第x题,之前做过k道题
让你判断之前错过的题数最少和最多是多少
如果数字连续就有可能是同时举办比赛。
感觉题目真正难的地方是在输入,把已参加的比赛读取到数组中,
再找到未参加的比赛,记录相邻比赛之间的差值是否等于1即可
#include <algorithm>#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <vector>#include <map>#define MAXN 4010#define ll long longusing namespace std;int c[MAXN];int main(void){int x, k, a;while(cin >> x >>k){int t1, t2, t3;int b[MAXN] = {0};for(int i=0; i<k; ++i){cin >> a;if(a == 2){ cin >> t1; b[t1] = 1; }else{ cin >> t2 >> t3; b[t2] = 1; b[t3] = 1; }}int t = 0;for(int i=1; i<x; ++i){if(!b[i]){c[t++] = i;}}//cout << "*******************" << endl;//for(int i=1; i<x; ++i)// cout << b[i] << endl;//cout << "*******************" << endl;int ans = 0;for(int i=0; i<t; ++i){c[i] = c[i+1] - c[i];if(c[i] == 1){i++;}ans++;}cout << ans << " " << t << endl;}return 0;}
- Codeforces Round #235 (Div. 2)B. Sereja and Contests
- codeforces B. Sereja and Contests
- Codeforces Round #215 (Div. 2) -B. Sereja and Suffixes
- Codeforces Round #215 (Div. 2) -B. Sereja and Suffixes
- Codeforces Round #215 (Div. 2) B. Sereja and Suffixes
- Codeforces Round #223 (Div. 2) B. Sereja and Stairs
- Codeforces Round #187 (Div. 2) B. Sereja and Array
- Codeforces Round #223 (Div. 2) B. Sereja and Stairs【模拟】
- codeforces 401B - Sereja and Contests
- Codeforces 401B Sereja and Contests(DP)
- CodeForces 401B Sereja and Contests
- Codeforces 401B Sereja and Contests【水题】
- Codeforces Round #223 (Div. 2)A. Sereja and Dima&&B. Sereja and Stairs
- B. Sereja and Contests
- B. Sereja and Contests
- codeforces#235_div2_B Sereja and Contests
- Codeforces Round #243 (Div. 1) B Sereja and Table
- Codeforces 401B Sereja and Contests(水题)
- 常用JavaScript
- file类renameTo使用小demo
- codeforces C. Team
- VC6.0使用教程-30分钟玩转Microsoft Visual C++ 6.0
- 华为机试题--数列求和
- Codeforces Round #235 (Div. 2)B. Sereja and Contests
- NSExpression
- codeforces A. Vanya and Cards
- 华为机试题---四舍五入
- 十款PHP开发者编码工具 你用过哪些?
- javac,使用"-d ."与省略-d的区别
- codeforces_235_div2解题报告
- 删除一个字符串里出现次数最多(少)的子字符串
- codeforces B. Sereja and Contests