Submission #416077

#TimeUsernameProblemLanguageResultExecution timeMemory
416077dreezyTropical Garden (IOI11_garden)C++17
Compilation error
0 ms0 KiB
#define pi pair<int,int> #define pb push_back #define ll long long #define f first #define s second const int maxn = 1e3 +5; //int level[maxn]; set<pi> graph[maxn]; ll bfs(int n, int k){ queue<tuple<int,int,int>> bfsq;//curnode, parent, level //for(pi adj : graph[n]){ //bfsq.push({adj.f, n, 1 }); //} bfsq.push({n,-1, 0}); ll ans = 0; //cout << k <<":\n\n"; while(bfsq.size()){ int node, parent, level; tie(node, parent,level) = bfsq.front(); bfsq.pop(); if(level > k) continue; if(graph[node].begin()->s != parent && parent != -1 ){ if(graph[node].size()>1 && next(graph[node].begin())->s == parent ) bfsq.push({next(graph[node].begin())->s, node, level + 1}); continue; } //cout << node <<", "<<parent<<", "<<level<<"\n"; if(level == k) { //cout <<"YES\n"; ans++; continue; } // if(graph[node].size() == 1){ // bfsq.push({graph[node].begin()->s, node, level +1}); //continue; //} for(pi adj : graph[node]){ auto fadj = graph[adj.s].begin(); if(fadj->s == node){ bfsq.push({adj.s, node, level +1}); //cout << level<<": "<<node <<"->"<<adj.s<<'\n'; } else if(graph[adj.s].size() > 1 && next(fadj)->s == node){ bfsq.push({fadj->s, adj.s, level + 2 }); //cout << level<<"+: "<<node <<"->"<<adj.s<<"->"<<fadj->s<<'\n'; } } } return ans; } void count_routes(int N, int M, int P, int R[][2], int Q, int G[]) { for(int i =0; i<M; i++){ graph[R[i][0]].insert({i,R[i][1] }); graph[R[i][1]].insert({i,R[i][0]}); } for(int i =0; i<Q; i++){ ll res = bfs(P, G[i]); answer(res); } }

Compilation message (stderr)

garden.cpp:9:1: error: 'set' does not name a type
    9 | set<pi> graph[maxn];
      | ^~~
garden.cpp: In function 'long long int bfs(int, int)':
garden.cpp:12:2: error: 'queue' was not declared in this scope
   12 |  queue<tuple<int,int,int>> bfsq;//curnode, parent, level
      |  ^~~~~
garden.cpp:12:8: error: 'tuple' was not declared in this scope
   12 |  queue<tuple<int,int,int>> bfsq;//curnode, parent, level
      |        ^~~~~
garden.cpp:12:14: error: expected primary-expression before 'int'
   12 |  queue<tuple<int,int,int>> bfsq;//curnode, parent, level
      |              ^~~
garden.cpp:17:2: error: 'bfsq' was not declared in this scope; did you mean 'bfs'?
   17 |  bfsq.push({n,-1, 0});
      |  ^~~~
      |  bfs
garden.cpp:25:3: error: 'tie' was not declared in this scope
   25 |   tie(node, parent,level) = bfsq.front();
      |   ^~~
garden.cpp:30:6: error: 'graph' was not declared in this scope
   30 |   if(graph[node].begin()->s != parent && parent != -1 ){
      |      ^~~~~
garden.cpp:31:31: error: 'next' was not declared in this scope
   31 |    if(graph[node].size()>1 && next(graph[node].begin())->s == parent )
      |                               ^~~~
garden.cpp:1:12: error: 'pair' was not declared in this scope; did you mean 'pi'?
    1 | #define pi pair<int,int>
      |            ^~~~
garden.cpp:51:7: note: in expansion of macro 'pi'
   51 |   for(pi adj : graph[node]){
      |       ^~
garden.cpp:1:17: error: expected primary-expression before 'int'
    1 | #define pi pair<int,int>
      |                 ^~~
garden.cpp:51:7: note: in expansion of macro 'pi'
   51 |   for(pi adj : graph[node]){
      |       ^~
garden.cpp:65:2: error: expected primary-expression before '}' token
   65 |  }
      |  ^
garden.cpp:63:4: error: expected ';' before '}' token
   63 |   }
      |    ^
      |    ;
   64 | 
   65 |  }
      |  ~  
garden.cpp:65:2: error: expected primary-expression before '}' token
   65 |  }
      |  ^
garden.cpp:63:4: error: expected ')' before '}' token
   63 |   }
      |    ^
      |    )
   64 | 
   65 |  }
      |  ~  
garden.cpp:51:6: note: to match this '('
   51 |   for(pi adj : graph[node]){
      |      ^
garden.cpp:65:2: error: expected primary-expression before '}' token
   65 |  }
      |  ^
garden.cpp: In function 'void count_routes(int, int, int, int (*)[2], int, int*)':
garden.cpp:74:4: error: 'graph' was not declared in this scope
   74 |    graph[R[i][0]].insert({i,R[i][1] });
      |    ^~~~~
garden.cpp:81:2: error: 'answer' was not declared in this scope
   81 |  answer(res);
      |  ^~~~~~