Submission #404881

#TimeUsernameProblemLanguageResultExecution timeMemory
404881JoshcTropical Garden (IOI11_garden)C++11
Compilation error
0 ms0 KiB
#include "garden.h" #include "gardenlib.h" #include <algorithm> #include <vector> using namespace std; const int INF = 2000000000; vector<int> edges[150001], edges2[300001], num[300001], num2[300001]; int dist[300001], dist2[300001], m[300001], m2[300001], x = 0, y = 0; void dfs(int v, int p, int cur, int dist[], int& len) { dist[v] = cur; for (int i : edges2[v]) { if (i == p) continue; if (dist[i] != INF) len = cur+1; else dfs(i, v, cur+1, dist, len); } } void count_routes(int n, int z, int p, int r[][2], int q, int g[]) { int n, z, p, q, a, b; for (int i=0; i<z; i++) { edges[r[i][0]].push_back(r[i][1]); edges[r[i][1]].push_back(r[i][0]); } for (int i=0; i<n; i++) { edges2[edges[i][0]*2 + (i == edges[edges[i][0]][0])].push_back(i*2); if (edges[i].size() == 1) edges2[edges[i][0]*2 + (i == edges[edges[i][0]][0])].push_back(i*2+1); else edges2[edges[i][1]*2 + (i == edges[edges[i][1]][0])].push_back(i*2+1); } fill(&dist[0], &dist[300001], INF); fill(&dist2[0], &dist2[300001], INF); dfs(p*2, p*2, 0, dist, x); dfs(p*2+1, p*2+1, 0, dist2, y); for (int i=0; i<2*n; i+=2) { if (dist[i] != INF) { m[dist[i]]++; if (x) num[dist[i]%x].push_back(dist[i]); } if (dist2[i] != INF) { m2[dist2[i]]++; if (y) num2[dist2[i]%y].push_back(dist2[i]); } } for (int i=0; i<2*n; i++) { sort(num[i].begin(), num[i].end()); sort(num2[i].begin(), num2[i].end()); } for (int i=0; i<q; i++) { int a = g[i]; int cur = x ? upper_bound(num[a%x].begin(), num[a%x].end(), a)-num[a%x].begin() : (a < 2*n ? m[a] : 0); int cur2 = y ? upper_bound(num2[a%y].begin(), num2[a%y].end(), a)-num2[a%y].begin() : (a < 2*n ? m2[a] : 0); answer(cur+cur2); } }

Compilation message (stderr)

garden.cpp: In function 'void count_routes(int, int, int, int (*)[2], int, int*)':
garden.cpp:22:9: error: declaration of 'int n' shadows a parameter
   22 |     int n, z, p, q, a, b;
      |         ^
garden.cpp:21:23: note: 'int n' previously declared here
   21 | void count_routes(int n, int z, int p, int r[][2], int q, int g[]) {
      |                   ~~~~^
garden.cpp:22:12: error: declaration of 'int z' shadows a parameter
   22 |     int n, z, p, q, a, b;
      |            ^
garden.cpp:21:30: note: 'int z' previously declared here
   21 | void count_routes(int n, int z, int p, int r[][2], int q, int g[]) {
      |                          ~~~~^
garden.cpp:22:15: error: declaration of 'int p' shadows a parameter
   22 |     int n, z, p, q, a, b;
      |               ^
garden.cpp:21:37: note: 'int p' previously declared here
   21 | void count_routes(int n, int z, int p, int r[][2], int q, int g[]) {
      |                                 ~~~~^
garden.cpp:22:18: error: declaration of 'int q' shadows a parameter
   22 |     int n, z, p, q, a, b;
      |                  ^
garden.cpp:21:56: note: 'int q' previously declared here
   21 | void count_routes(int n, int z, int p, int r[][2], int q, int g[]) {
      |                                                    ~~~~^
garden.cpp:22:21: warning: unused variable 'a' [-Wunused-variable]
   22 |     int n, z, p, q, a, b;
      |                     ^
garden.cpp:22:24: warning: unused variable 'b' [-Wunused-variable]
   22 |     int n, z, p, q, a, b;
      |                        ^