Submission #1017990

#TimeUsernameProblemLanguageResultExecution timeMemory
1017990PAndaSTropical Garden (IOI11_garden)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #include "garden.h" #include "gardenlib.h" #define pib pair<int, bool> using namespace std; void count_routes(int n, int m, int p, int r[][2], int q, int g[]){ vector<vector<pair<int, int>>> gr(n, vector<pair<int, int>>(0)); for(int i = 0; i < M; i++){ gr[r[i][0]].push_back(pair<int, int>(i, r[i][1])); gr[r[i][1]].push_back(pair<int, int>(i, r[i][0])); } vector< vector< vector<pib> > > jmp(n, vector< vector<pib> >(18, vector< pair<int, bool> >(2))); for(int i = 0; i < n; i++){ if(!gr[i].size()){ jmp[i][0][0] = pib(i, 1); jmp[i][0][1] = pib(i, 1); } jmp[i][0][0] = pib(gr[i][0].second, 0); if(gr[jmp[i][0][0].first][0].second == i){ jmp[i][0][0].second = 1; } if(gr[i].size() == 1) jmp[i][0][1] = jmp[i][0][0]; else{ jmp[i][0][1] = pib(gr[i][1].second, 0); if(gr[jmp[i][0][1].first][0].second == i) jmp[i][0][1].second = 1; } } for(int j = 1; j < 18; j++){ for(int i = 0; i < n; i++){ jmp[i][j][0] = jmp[jmp[i][j - 1][0].first][j - 1][jmp[i][j - 1][0].second]; jmp[i][j][1] = jmp[jmp[i][j - 1][1].first][j - 1][jmp[i][j - 1][1].second]; } } for(int j = 0; j < 3; j++){ for(int i = 0; i < n; i++) cout << i << ' ' << j << ' ' << jmp[i][j][0].first << ' ' << jmp[i][j][0].second << ' ' << jmp[i][j][1].first << ' ' << jmp[i][j][1].second << '\n'; } cout << '\n'; int cur_n, cur_s, cnt = 0, tmp, tmp2, tmp3, tmp4; for(int i = 0; i < q; i++){ cnt = 0; for(int j = 0; j < n; j++){ tmp = g[i]; cur_n = j; cur_s = 0; tmp2 = 1; while(tmp){ if(tmp & tmp2){ tmp3 = cur_n; tmp4 = cur_s; cout << cur_n << ' ' << cur_s << ' '; cur_n = jmp[tmp3][tmp2 - 1][tmp4].first; cur_s = jmp[tmp3][tmp2 - 1][tmp4].second; tmp -= tmp2; } tmp2 <<= 1; } cout << cur_n << ' ' << cur_s << '\n'; if(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:11:24: error: 'M' was not declared in this scope
   11 |     for(int i = 0; i < M; i++){
      |                        ^