Submission #576009

#TimeUsernameProblemLanguageResultExecution timeMemory
576009I_am_balancingEaster Eggs (info1cup17_eastereggs)C++17
Compilation error
0 ms0 KiB
int findEgg(int n, vector<pair<int,int>> bridges){ using ll = long long; vector<vector<ll>> g(n+1); vector<ll> ban(n+1),sub(n+1); ll crsz = n; for(auto[a,b] : bridges)g[a].pb(b),g[b].pb(a); function<void(ll,ll)> cnt = [&](ll v, ll p){ sub[v] = 1; for(ll to : g[v]){ if(to == p || ban[to])continue; cnt(to,v); sub[v]+=sub[to]; } }; function<ll(ll,ll)> findCentroid = [&](ll v, ll p){ for(ll to : g[v]){ if(to == p || ban[to])continue; if(sub[to] > crsz/2)return findCentroid(to,v); } return v; }; vector<int> csub; function<void(ll,ll)> cS = [&](ll v, ll p){ csub.pb(v); for(ll to : g[v]){ if(to == p || ban[to]){ cout << "rejected : " << v << " -> " << to << ' ' << ban[to] << ' ' << p << '\n'; continue; } cS(to,v); } }; function<ll(ll)> centr = [&](ll v){ cnt(v,0); crsz = sub[v]; if(sub[v] == 1)return v; if(sub[v] == 2){ if(query({v}))return v; else{ for(ll to : g[v]){ if(ban[to])continue; return to; } } } v = findCentroid(v,0); cout << "Centroid: " << v << '\n'; ll l = 1, r = 0; for(ll to : g[v]){ if(ban[to])continue; r++; } while(r-l+1>1){ ll mid = (l+r)>>1; ll t = 0; for(ll to : g[v]){ if(ban[to])continue; t++; if(l<=t && t<=mid)cS(to,v); } csub.pb(v); if(query(csub)){ r = mid; } else l = mid+1,ban[v]=1; csub.clear(); } ll t = 0; for(ll to : g[v]){ if(ban[to])continue; t++; if(t != r){ ban[to]=1; } } for(ll to : g[v]){ if(ban[to])continue; return centr(to); } }; return centr(1); }

Compilation message (stderr)

eastereggs.cpp:1:20: error: 'vector' has not been declared
    1 | int findEgg(int n, vector<pair<int,int>> bridges){
      |                    ^~~~~~
eastereggs.cpp:1:26: error: expected ',' or '...' before '<' token
    1 | int findEgg(int n, vector<pair<int,int>> bridges){
      |                          ^
eastereggs.cpp: In function 'int findEgg(int, int)':
eastereggs.cpp:3:5: error: 'vector' was not declared in this scope
    3 |     vector<vector<ll>> g(n+1);
      |     ^~~~~~
eastereggs.cpp:3:21: error: expected primary-expression before '>>' token
    3 |     vector<vector<ll>> g(n+1);
      |                     ^~
eastereggs.cpp:3:24: error: 'g' was not declared in this scope
    3 |     vector<vector<ll>> g(n+1);
      |                        ^
eastereggs.cpp:4:14: error: expected primary-expression before '>' token
    4 |     vector<ll> ban(n+1),sub(n+1);
      |              ^
eastereggs.cpp:4:16: error: 'ban' was not declared in this scope
    4 |     vector<ll> ban(n+1),sub(n+1);
      |                ^~~
eastereggs.cpp:4:25: error: 'sub' was not declared in this scope
    4 |     vector<ll> ban(n+1),sub(n+1);
      |                         ^~~
eastereggs.cpp:7:21: error: 'bridges' was not declared in this scope
    7 |     for(auto[a,b] : bridges)g[a].pb(b),g[b].pb(a);
      |                     ^~~~~~~
eastereggs.cpp:9:5: error: 'function' was not declared in this scope; did you mean 'union'?
    9 |     function<void(ll,ll)> cnt = [&](ll v, ll p){
      |     ^~~~~~~~
      |     union
eastereggs.cpp:9:24: error: expression list treated as compound expression in functional cast [-fpermissive]
    9 |     function<void(ll,ll)> cnt = [&](ll v, ll p){
      |                        ^
eastereggs.cpp:9:14: error: expected primary-expression before 'void'
    9 |     function<void(ll,ll)> cnt = [&](ll v, ll p){
      |              ^~~~
eastereggs.cpp:18:22: error: expression list treated as compound expression in functional cast [-fpermissive]
   18 |     function<ll(ll,ll)> findCentroid = [&](ll v, ll p){
      |                      ^
eastereggs.cpp:18:16: error: expected primary-expression before '(' token
   18 |     function<ll(ll,ll)> findCentroid = [&](ll v, ll p){
      |                ^
eastereggs.cpp:18:19: error: expected primary-expression before ',' token
   18 |     function<ll(ll,ll)> findCentroid = [&](ll v, ll p){
      |                   ^
eastereggs.cpp:18:22: error: expected primary-expression before ')' token
   18 |     function<ll(ll,ll)> findCentroid = [&](ll v, ll p){
      |                      ^
eastereggs.cpp:18:25: error: 'findCentroid' was not declared in this scope
   18 |     function<ll(ll,ll)> findCentroid = [&](ll v, ll p){
      |                         ^~~~~~~~~~~~
eastereggs.cpp:25:12: error: expected primary-expression before 'int'
   25 |     vector<int> csub;
      |            ^~~
eastereggs.cpp:26:24: error: expression list treated as compound expression in functional cast [-fpermissive]
   26 |     function<void(ll,ll)> cS = [&](ll v, ll p){
      |                        ^
eastereggs.cpp:26:14: error: expected primary-expression before 'void'
   26 |     function<void(ll,ll)> cS = [&](ll v, ll p){
      |              ^~~~
eastereggs.cpp:37:16: error: expected primary-expression before '(' token
   37 |     function<ll(ll)> centr = [&](ll v){
      |                ^
eastereggs.cpp:37:19: error: expected primary-expression before ')' token
   37 |     function<ll(ll)> centr = [&](ll v){
      |                   ^
eastereggs.cpp:37:22: error: 'centr' was not declared in this scope
   37 |     function<ll(ll)> centr = [&](ll v){
      |                      ^~~~~
eastereggs.cpp: In lambda function:
eastereggs.cpp:38:9: error: 'cnt' was not declared in this scope; did you mean 'int'?
   38 |         cnt(v,0);
      |         ^~~
      |         int
eastereggs.cpp:42:16: error: 'query' was not declared in this scope
   42 |             if(query({v}))return v;
      |                ^~~~~
eastereggs.cpp:51:9: error: 'cout' was not declared in this scope
   51 |         cout << "Centroid: " << v << '\n';
      |         ^~~~
eastereggs.cpp:63:35: error: 'cS' was not declared in this scope
   63 |                 if(l<=t && t<=mid)cS(to,v);
      |                                   ^~
eastereggs.cpp:65:13: error: 'csub' was not declared in this scope
   65 |             csub.pb(v);
      |             ^~~~
eastereggs.cpp:66:16: error: 'query' was not declared in this scope
   66 |             if(query(csub)){
      |                ^~~~~