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 2 2 1 2 2
0 0
9 3 1 2 3 2 8 1 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.
题意:一共有n场比赛,m种情况。当为1时,第一个数字是div2,第二个数字为div1。当为2时,其后是div2。div1和div2是连续的。也就是每场div比赛都有其标识。问他错过最少和最多div2比赛是多少。
题解:把参加过的div比赛都标记好。如果有两个连续的就可以假设是div1和div2一起的。这样就能求出最少错过多少场,然后没有被标记的都记作最多错过的场次。
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <list>
#include <vector>
using namespace std;
//#define DEBUG
int main()
{
#ifdef DEBUG
freopen("cin.txt", "r", stdin);
freopen("cout.txt", "w", stdout);
#endif
int n,m,i;
int f[4010];
while (~scanf("%d%d",&n,&m))
{
memset(f,0,sizeof(f));
for (i=1;i<=m;i++)
{
int a,c,b;
scanf("%d",&a);
if (a==1)
{
scanf("%d%d",&b,&c);
f[b]=1;f[c]=1;
}
else if (a==2)
{
scanf("%d",&b);
f[b]=1;
}
}
int s=0,min=0;
for (i=1;i<n;i++)
if (f[i]==0)
{
if (f[i+1]==0 && i+1<n)
{
f[i+1]=1;
s++;
}
min++;
s++;
}
printf("%d %d\n",min,s);
}
return 0;
}
本题描述了Sereja作为一位初学者如何参与Codeforces的竞赛,并通过已知条件计算他可能错过的最少与最多的Div2轮次。题目要求解析输入数据,确定Sereja可能错过的竞赛范围。
1116

被折叠的 条评论
为什么被折叠?



