CF401B.Sereja and Contests
普及-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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: _Div_1 (for advanced coders) and _Div_2 (for beginner coders). Two rounds, _Div_1 and _Div_2, can go simultaneously, (_Div_1 round cannot be held without _Div_2) 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 _Div_1 round is always greater.
Sereja is a beginner coder, so he can take part only in rounds of _Div_2 type. At the moment he is taking part in a _Div_2 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 _Div_2 rounds could he have missed? Help him find these two numbers.
Sereja 是一名程序员,他喜欢参加 Codesorfes 的比赛。然而,乌日兰德(Uzhland)的网络连接状况不佳,因此 Sereja 有时会错过某些比赛。
Codesorfes 的比赛分为两种类型:_Div_1(面向高级程序员)和 _Div_2(面向初学者)。两类比赛可能同时举行(但 _Div_1 比赛必须与 _Div_2 比赛同时进行,即不存在没有对应 _Div_2 的 _Div_1 比赛),其余情况下所有比赛在时间上互不重叠。每场比赛都有一个唯一的标识符——一个正整数。所有比赛按其开始时间顺序编号(无空缺),编号即为其标识符。若两场比赛同时举行,则它们的标识符相差恰好为 1,且 _Div_1 比赛的标识符总是更大。
Sereja 是一名初学者程序员,因此他只能参加 _Div_2 类型的比赛。目前他正在参加一场 _Div_2 比赛,其标识符为 x。Sereja 记得非常清楚:在此轮之前,他恰好参加过 k 场比赛。此外,他还记得自己参加过的所有比赛的标识符,以及所有与这些比赛同时举行的(即标识符相差为 1 的)比赛的标识符。Sereja 对于他错过的其他比赛则毫无记忆。
Sereja 想知道:他可能错过的 _Div_2 比赛的最少数量和最多数量分别是多少?请帮助他求出这两个数值。
输入格式
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 _num_2 _num_1" (where _num_2 is the identifier of this _Div_2 round, _num_1 is the identifier of the _Div_1 round). It is guaranteed that _num_1 - _num_2 = 1. If Sereja took part in a usual _Div_2 round, then the corresponding line looks like: "2 num" (where num is the identifier of this _Div_2 round). It is guaranteed that the identifiers of all given rounds are less than x.
第一行包含两个整数:x(1 ≤ x ≤ 4000)—— 今天 Sereja 参加的场次编号;以及 k(0 ≤ k < 4000)—— 他此前参加过的场次数。
接下来的 k 行描述了 Sereja 此前参加过的各场比赛。若 Sereja 参加的是两场同时进行的比赛,则对应行格式为:“1 _num_2 _num_1”(其中 _num_2 是该场 Div.2 比赛的编号,_num_1 是对应的 Div.1 比赛的编号)。保证 _num_1 − _num_2 = 1。若 Sereja 参加的是常规的 Div.2 比赛,则对应行格式为:“2 num”(其中 num 是该场 Div.2 比赛的编号)。保证所有给出的比赛编号均小于 x。
输出格式
Print in a single line two integers — the minimum and the maximum number of rounds that Sereja could have missed.
在一行中输出两个整数——Sereja 可能错过的最少轮数和最多轮数。
输入输出样例
输入#1
3 2 2 1 2 2
输出#1
0 0
输入#2
9 3 1 2 3 2 8 1 4 5
输出#2
2 3
输入#3
10 0
输出#3
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 _Div_2 round and the round with identifier 6 will be synchronous with the _Div_1 round.
The maximum number of rounds equals 3. In this case all unused identifiers belong to usual _Div_2 rounds.
在第二个样例中,未使用的比赛编号为 1、6、7。Sereja 可能错过的最少比赛场数为 2。此时,编号为 1 的比赛将是一场普通的 _Div_2 比赛,编号为 6 的比赛将与一场 _Div_1 比赛同步举行。
最多可能的比赛场数为 3。此时,所有未使用的编号均属于普通的 _Div_2 比赛。
输入解题思路,AI测评打分。不知道怎么写?