제출 #1271967

#제출 시각아이디문제언어결과실행 시간메모리
1271967tredsused70Tropical Garden (IOI11_garden)C++20
컴파일 에러
0 ms0 KiB
int nextv[nmax * 2], cnt[nmax * 2]; int visited[nmax * 2]; int target; int n_; int cycle[nmax * 2], dist1[nmax * 2], dist2[nmax * 2]; void fill_cycle_dist(int v) { if(v == target) { int nv = nextv[v]; int cur = cycle[v] - 1; while(nv != v) { dist1[nv] = cur; cur--; nv = nextv[nv]; } } if(v == target + n_) { int nv = nextv[v]; int cur = cycle[v] - 1; while(nv != v) { dist2[nv] = cur; cur--; nv = nextv[nv]; } } return ; } void dfs(int v) { int nv = nextv[v]; if(v == target) dist1[v] = 0; if(v == target + n_) dist2[v] = 0; visited[v] = 1; if(visited[nv] == 2) { if(dist1[nv] != -1) dist1[v] = dist1[nv] + 1; if(dist2[nv] != -1) dist2[v] = dist2[nv] + 1; visited[v] = 2; return ; } if(visited[nv] == 1) { int len = 1; while(nv != v) { len++; nv = nextv[nv]; } nv = nextv[v]; cycle[v] = len; while(nv != v) { cycle[nv] = len; nv = nextv[nv]; } fill_cycle_dist(v); visited[v] = 2; return ; } dfs(nv); visited[v] = 2; if(cycle[v]) { fill_cycle_dist(v); return ; } if(dist1[nv] != -1) dist1[v] = dist1[nv] + 1; if(dist2[nv] != -1) dist2[v] = dist2[nv] + 1; return ; } void count_routes(int n, int m, int t, int edges[][2], int q, int query[]) { n_ = n; fill(nextv, nextv + nmax * 2, -1); fill(dist1, dist1 + nmax * 2, -1); fill(dist2, dist2 + nmax * 2, -1); fill(cnt, cnt + nmax * 2, 0); fill(cycle, cycle + nmax * 2, 0); fill(visited, visited + nmax * 2, 0); for(int i = 0; i < m; i++) { for(int j = 0; j < 2; j++) { if(nextv[edges[i][j]] == -1) { if(cnt[edges[i][j ^ 1]]) nextv[edges[i][j]] = edges[i][j ^ 1]; else nextv[edges[i][j]] = edges[i][j ^ 1] + n; } else { if(nextv[edges[i][j] + n] == -1) { if(cnt[edges[i][j ^ 1]]) nextv[edges[i][j] + n] = edges[i][j ^ 1]; else nextv[edges[i][j] + n] = edges[i][j ^ 1] + n; } } } cnt[edges[i][0]]++; cnt[edges[i][1]]++; } for(int i = 0; i < n; i++) { if(cnt[i] == 1) nextv[i + n] = nextv[i]; //cout << i << " " << nextv[i] << " " << nextv[i + n] << "\n"; } target = t; for(int i = 0; i < n; i++) { if(!visited[i]) dfs(i); } //for(int i = 0; i < n; i++) { //cout << i << "\n" << dist1[i] << " " << dist2[i] << "\n"; //} for(int i = 0; i < q; i++) { int ans = 0; for(int j = 0; j < n; j++) { if((dist1[j] == query[i]) || (dist1[j] >= 0 && dist1[j] < query[i] && cycle[t] && (query[i] - dist1[j]) % cycle[t] == 0)) ans++; else if((dist2[j] == query[i]) || (dist2[j] >= 0 && dist2[j] < query[i] && cycle[t + n] && (query[i] - dist2[j]) % cycle[t + n] == 0)) ans++; } answer(ans); } return ; }

컴파일 시 표준 에러 (stderr) 메시지

garden.cpp:2:11: error: 'nmax' was not declared in this scope
    2 | int nextv[nmax * 2], cnt[nmax * 2];
      |           ^~~~
garden.cpp:2:26: error: 'nmax' was not declared in this scope
    2 | int nextv[nmax * 2], cnt[nmax * 2];
      |                          ^~~~
garden.cpp:3:13: error: 'nmax' was not declared in this scope
    3 | int visited[nmax * 2];
      |             ^~~~
garden.cpp:6:11: error: 'nmax' was not declared in this scope
    6 | int cycle[nmax * 2], dist1[nmax * 2], dist2[nmax * 2];
      |           ^~~~
garden.cpp:6:28: error: 'nmax' was not declared in this scope
    6 | int cycle[nmax * 2], dist1[nmax * 2], dist2[nmax * 2];
      |                            ^~~~
garden.cpp:6:45: error: 'nmax' was not declared in this scope
    6 | int cycle[nmax * 2], dist1[nmax * 2], dist2[nmax * 2];
      |                                             ^~~~
garden.cpp: In function 'void fill_cycle_dist(int)':
garden.cpp:10:18: error: 'nextv' was not declared in this scope
   10 |         int nv = nextv[v];
      |                  ^~~~~
garden.cpp:11:19: error: 'cycle' was not declared in this scope
   11 |         int cur = cycle[v] - 1;
      |                   ^~~~~
garden.cpp:13:13: error: 'dist1' was not declared in this scope
   13 |             dist1[nv] = cur;
      |             ^~~~~
garden.cpp:19:18: error: 'nextv' was not declared in this scope
   19 |         int nv = nextv[v];
      |                  ^~~~~
garden.cpp:20:19: error: 'cycle' was not declared in this scope
   20 |         int cur = cycle[v] - 1;
      |                   ^~~~~
garden.cpp:22:13: error: 'dist2' was not declared in this scope
   22 |             dist2[nv] = cur;
      |             ^~~~~
garden.cpp: In function 'void dfs(int)':
garden.cpp:31:14: error: 'nextv' was not declared in this scope
   31 |     int nv = nextv[v];
      |              ^~~~~
garden.cpp:33:9: error: 'dist1' was not declared in this scope
   33 |         dist1[v] = 0;
      |         ^~~~~
garden.cpp:35:9: error: 'dist2' was not declared in this scope
   35 |         dist2[v] = 0;
      |         ^~~~~
garden.cpp:36:5: error: 'visited' was not declared in this scope
   36 |     visited[v] = 1;
      |     ^~~~~~~
garden.cpp:38:12: error: 'dist1' was not declared in this scope
   38 |         if(dist1[nv] != -1)
      |            ^~~~~
garden.cpp:40:12: error: 'dist2' was not declared in this scope
   40 |         if(dist2[nv] != -1)
      |            ^~~~~
garden.cpp:52:9: error: 'cycle' was not declared in this scope
   52 |         cycle[v] = len;
      |         ^~~~~
garden.cpp:63:8: error: 'cycle' was not declared in this scope
   63 |     if(cycle[v]) {
      |        ^~~~~
garden.cpp:67:8: error: 'dist1' was not declared in this scope
   67 |     if(dist1[nv] != -1)
      |        ^~~~~
garden.cpp:69:8: error: 'dist2' was not declared in this scope
   69 |     if(dist2[nv] != -1)
      |        ^~~~~
garden.cpp: In function 'void count_routes(int, int, int, int (*)[2], int, int*)':
garden.cpp:76:10: error: 'nextv' was not declared in this scope
   76 |     fill(nextv, nextv + nmax * 2, -1);
      |          ^~~~~
garden.cpp:76:25: error: 'nmax' was not declared in this scope
   76 |     fill(nextv, nextv + nmax * 2, -1);
      |                         ^~~~
garden.cpp:76:5: error: 'fill' was not declared in this scope
   76 |     fill(nextv, nextv + nmax * 2, -1);
      |     ^~~~
garden.cpp:77:10: error: 'dist1' was not declared in this scope
   77 |     fill(dist1, dist1 + nmax * 2, -1);
      |          ^~~~~
garden.cpp:78:10: error: 'dist2' was not declared in this scope
   78 |     fill(dist2, dist2 + nmax * 2, -1);
      |          ^~~~~
garden.cpp:79:10: error: 'cnt' was not declared in this scope; did you mean 'int'?
   79 |     fill(cnt, cnt + nmax * 2, 0);
      |          ^~~
      |          int
garden.cpp:80:10: error: 'cycle' was not declared in this scope
   80 |     fill(cycle, cycle + nmax * 2, 0);
      |          ^~~~~
garden.cpp:81:10: error: 'visited' was not declared in this scope
   81 |     fill(visited, visited + nmax * 2, 0);
      |          ^~~~~~~
garden.cpp:124:9: error: 'answer' was not declared in this scope
  124 |         answer(ans);
      |         ^~~~~~