CSES - Datatähti Open 2017 - Results
Submission details
Task:Tunnels
Sender:thuustalu
Submission time:2017-01-21 02:54:41 +0200
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:12:5: error: 'root' was not declared in this scope
     root[i] = i;
     ^

Code

#include <iostream>
#include <stdlib.h>

const int MAX_ROOM = 100005;

using namespace std;

int depc [MAX_ROOM], arrc [MAX_ROOM];

int main () {
  for (int i = 0; i < MAX_ROOM; i++) {
    root[i] = i;
  }
  
  int roomc, edgec;
  cin >> roomc >> edgec;

  for (int i = 0; i < edgec; i++) {
    int u, v;
    cin >> u >> v;
  
    depc[u]++;
    arrc[v]++;
  }

  int ans = 0;
  for (int i = 1; i <= roomc; i++) {
    if (depc[i] > arrc[i]) {
      ans += depc[i] - arrc[i];
    }
  }

  cout << max(ans, 1) << endl;
}