Submission #410359

#TimeUsernameProblemLanguageResultExecution timeMemory
410359600MihneaTropical Garden (IOI11_garden)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "garden.h" #include "gardenlib.h" using namespace std; const int K = 35; const int N = 2 * 150000 + 7; int n, m, city, from[N], to[N], y; vector<int> g[N]; void add_edge(int a, int b) { from[y] = a; to[y] = b; g[a].push_back(y); y++; } int nxt[K][N]; void count_routes(int nn, int mm, int pp, int rr[][2], int qq, int gg[]) { n = nn; m = mm; city = pp; y = 0; for (int i = 0; i < n; i++) { g[i].clear(); } for (int i = 0; i < m; i++) { add_edge(rr[i][0], rr[i][1]); add_edge(rr[i][1], rr[i][0]); } for (int i = 0; i < y; i++) { if ((int) g[b].size() == 1) { nxt[0][i] = i ^ 1; } else { if ((i ^ 1) == g[b][0]) { nxt[0][i] = g[b][1]; } else { nxt[0][i] = g[b][0]; } } } for (int bit = 1; bit < K; bit++) { for (int i = 0; i < y; i++) { nxt[bit][i] = nxt[bit - 1][nxt[bit - 1][i]]; } } for (int qind = 0; qind < qq; qind++) { int len = gg[qind], sol = 0; for (int a = 0; a < n; a++) { int cur = g[a][0]; for (int bit = 0; (1 << bit) <= len; bit++) { if (len & (1 << bit)) { cur = nxt[bit][cur]; } } if (from[cur] == city) { sol++; } } answer(sol); } }

Compilation message (stderr)

garden.cpp: In function 'void count_routes(int, int, int, int (*)[2], int, int*)':
garden.cpp:34:17: error: 'b' was not declared in this scope
   34 |     if ((int) g[b].size() == 1) {
      |                 ^