Submission #1099661

#TimeUsernameProblemLanguageResultExecution timeMemory
1099661tuannmEaster Eggs (info1cup17_eastereggs)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #include "grader.h" #define ii pair<int, int> #define fi first #define se second #define pb push_back using namespace std; const int maxN = 520; bool removed[maxN]; int sz[maxN], in[maxN], out[maxN], cnt; vector<int> adj[maxN]; void DFS(int u = 1, int p = 0){ in[u] = ++cnt; sz[u] = 1; for(int v : adj[u]){ if(removed[v] || v == p) continue; DFS(v, u); sz[u] += sz[v]; } out[u] = cnt; } int findEgg(int N, vector<ii> bridges){ for(auto [u, v] : bridges) adj[u].pb(v), adj[v].pb(u); for(int Q = 1; Q <= 9; ++Q){ cnt = 0; int root = 0; for(int i = 1; i <= n; ++i){ if(removed[i]) continue; root = i; break; } DFS(root); int zz = sz[root] / 2; int s = root; for(int i = 1; i <= n; ++i){ if(removed[i]) continue; if(abs(zz - sz[i]) < abs(zz - sz[s])) s = i; } vector<int> vec; for(int i = 1; i <= n; ++i){ if(removed[i]) continue; if(in[s] <= in[i] && in[i] <= out[s]) vec.pb(i); } if(query(vec)){ for(int i = 1; i <= n; ++i){ if(removed[i]) continue; if(in[s] <= in[i] && in[i] <= out[s]) continue; removed[i] = true; } } else{ for(int i : vec) removed[i] = true; } int cntRem = 0; for(int i = 1; i <= n; ++i) cntRem += !removed[i]; if(cntRem == 1){ for(int i = 1; i <= n; ++i) if(!removed[i]) return i; } } return -1; }

Compilation message (stderr)

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:38:29: error: 'n' was not declared in this scope
   38 |         for(int i = 1; i <= n; ++i){
      |                             ^
eastereggs.cpp:50:29: error: 'n' was not declared in this scope
   50 |         for(int i = 1; i <= n; ++i){
      |                             ^
eastereggs.cpp:60:29: error: 'n' was not declared in this scope
   60 |         for(int i = 1; i <= n; ++i){
      |                             ^
eastereggs.cpp:69:33: error: 'n' was not declared in this scope
   69 |             for(int i = 1; i <= n; ++i){
      |                                 ^
eastereggs.cpp:86:29: error: 'n' was not declared in this scope
   86 |         for(int i = 1; i <= n; ++i)
      |                             ^
eastereggs.cpp:90:33: error: 'n' was not declared in this scope
   90 |             for(int i = 1; i <= n; ++i)
      |                                 ^