Submission #39546

#TimeUsernameProblemLanguageResultExecution timeMemory
39546smu201111192Tropical Garden (IOI11_garden)C++14
Compilation error
0 ms0 KiB
#include <iostream> #include <cstdio> #include <string> #include <sstream> #include <algorithm> #include <set> #include <numeric> #include <cmath> #include <map> #include <vector> #include <queue> #include <stack> #include <cstring> #include <queue> #include <numeric> #include <iomanip> #define ll long long using namespace std; void count_routes(int N, int M, int P, int R[][2], int Q, int G[]) { ::N= N; for(int i=0;i<M;i++){ adj[R[i][0]].push_back({i,R[i][1]}); adj[R[i][1]].push_back({i,R[i][0]}); } for(int i=0;i<N;i++){ sort(adj[i].begin(),adj[i].end()); } for(int i=0;i<N;i++){ int here = i; int there = adj[i][0].second; nxt[i][0] = adj[i][0].second; if(adj[there][0].second == here) nxt[here][0] += N; there = nxt[i+N][0] = (adj[i].size() == 1) ? adj[i][0].second : adj[i][1].second; here = i + N; if(adj[there][0].second == here-N) nxt[here][0] += N; } for(int i=1;i<30;i++){ for(int j=0;j<2*N;j++){ nxt[j][i] = nxt[nxt[j][i-1]][i-1]; } } for(int k=0;k<Q;k++){ // 반 int cnt = 0; for(int i=0;i<N;i++){ //시작점 int bit = G[k]; int j = 0; int cur = i; while(bit){ if(bit & (1<<j)){ bit -= (1<<j); cur = nxt[cur][j]; } j++; } if(cur == P || cur -N == P) cnt++; } answer(cnt); } }

Compilation message (stderr)

garden.cpp: In function 'void count_routes(int, int, int, int (*)[2], int, int*)':
garden.cpp:21:7: error: '::N' has not been declared
     ::N= N;
       ^
garden.cpp:23:9: error: 'adj' was not declared in this scope
         adj[R[i][0]].push_back({i,R[i][1]});
         ^~~
garden.cpp:27:14: error: 'adj' was not declared in this scope
         sort(adj[i].begin(),adj[i].end());
              ^~~
garden.cpp:31:21: error: 'adj' was not declared in this scope
         int there = adj[i][0].second;
                     ^~~
garden.cpp:32:9: error: 'nxt' was not declared in this scope
         nxt[i][0] = adj[i][0].second;
         ^~~
garden.cpp:32:9: note: suggested alternative: 'exit'
         nxt[i][0] = adj[i][0].second;
         ^~~
         exit
garden.cpp:40:13: error: 'nxt' was not declared in this scope
             nxt[j][i] = nxt[nxt[j][i-1]][i-1];
             ^~~
garden.cpp:40:13: note: suggested alternative: 'exit'
             nxt[j][i] = nxt[nxt[j][i-1]][i-1];
             ^~~
             exit
garden.cpp:52:27: error: 'nxt' was not declared in this scope
                     cur = nxt[cur][j];
                           ^~~
garden.cpp:58:9: error: 'answer' was not declared in this scope
         answer(cnt);
         ^~~~~~