题目链接:http://codeforces.com/problemset/problem/401/B
题目大意:正在做第x场比赛,之前做过k场,判断之前最少和最多错过了几场比赛,连续的场次可能是同时举办比赛。
题目分析:div2可以单独举办,div1必须和div2一起(编号连续),其他没有什么需要注意了。
代码参考:
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
const int N = 5000;
bool vis[N];
int main()
{
int n, m, t, i, j, k, div, a, b, c;
while (~scanf("%d%d", &n, &m))
{
memset(vis, 0, sizeof(vis));
for (i = 0; i < m; ++i)
{
scanf("%d", &div);
if (div == 1)
{
scanf("%d%d", &a, &b);
vis[a] = vis[b] = 1;
}
else
{
scanf("%d", &c);
vis[c] = 1;
}
}
int cnt = 0;
int mx = 0, mi = 0;
vis[n] = true;
for (i = 1; i < n; ++i)
{
if (!vis[i])
{
++mx;
++mi;
if (!vis[i + 1])
{
++mx;
++i;
}
}
}
int ans;
if (cnt % 2 == 0)
{
ans = cnt / 2;
}
else
{
ans = cnt / 2 + 1;
}
printf("%d %d\n", mi, mx);
}
return 0;
}