Codeforces Round #235 (Div. 2), problem: (B) Sereja and Contests:
http://codeforces.com/contest/401/problem/B
Codeforces Round #235 (Div. 2), problem: (B) Sereja and Contests solution: http://ideone.com/wYEA7K
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main() {
int x, k, a[4005], b[4005], cnt, dif, p, q, n;
memset(a, 0, sizeof(a));
memset(b, 0, sizeof(b));
scanf("%d%d", &x, &k);
a[x-1]++;
cnt=dif=0;
for(int i=0; i<k; i++) {
scanf("%d", &n);
if(n==1) {
scanf("%d%d", &p, &q);
a[p-1]++;
a[q-1]++;
}
else {
scanf("%d", &p);
a[p-1]++;
}
}
for(int i=0; i<x; i++) {
if(a[i]==0) {
cnt++;
}
if(a[i]==0 && a[i+1]==0 && b[i]==0) {
dif++;
b[i]++;
b[i+1]++;
}
}
printf("%d %d\n", cnt-dif, cnt);
return 0;
}
No comments:
Post a Comment