fork download
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cstring>
  4. using namespace std;
  5.  
  6. int main() {
  7. int x, k, a[4005], b[4005], cnt, dif, p, q, n;
  8. memset(a, 0, sizeof(a));
  9. memset(b, 0, sizeof(b));
  10. scanf("%d%d", &x, &k);
  11. a[x-1]++;
  12. cnt=dif=0;
  13. for(int i=0; i<k; i++) {
  14. scanf("%d", &n);
  15. if(n==1) {
  16. scanf("%d%d", &p, &q);
  17. a[p-1]++;
  18. a[q-1]++;
  19. }
  20. else {
  21. scanf("%d", &p);
  22. a[p-1]++;
  23. }
  24. }
  25. for(int i=0; i<x; i++) {
  26. if(a[i]==0) {
  27. cnt++;
  28. }
  29. if(a[i]==0 && a[i+1]==0 && b[i]==0) {
  30. dif++;
  31. b[i]++;
  32. b[i+1]++;
  33. }
  34. }
  35. printf("%d %d\n", cnt-dif, cnt);
  36. return 0;
  37. }
Success #stdin #stdout 0s 3300KB
stdin
10 0
stdout
5 9