Submission #511067

#TimeUsernameProblemLanguageResultExecution timeMemory
511067tabrTropical Garden (IOI11_garden)C++17
0 / 100
1 ms460 KiB
#include <bits/stdc++.h> using namespace std; #ifdef tabr #include "library/debug.cpp" #else #define debug(...) #endif #include "garden.h" #include "gardenlib.h" void count_routes(int n, int m, int p, int r[][2], int q, int k[]) { vector<vector<int>> g(n); for (int i = 0; i < m; i++) { g[r[i][0]].emplace_back(r[i][1]); g[r[i][1]].emplace_back(r[i][0]); } vector<vector<int>> nxt(30, vector<int>(2 * n)); for (int i = 0; i < n; i++) { nxt[0][i] = g[i][0] + n; nxt[0][i + n] = (g[i].empty() ? g[i][0] + n : g[i][1]); } for (int i = 1; i < 30; i++) { for (int j = 0; j < 2 * n; j++) { nxt[i][j] = nxt[i - 1][nxt[i - 1][j]]; } } for (int i = 0; i < q; i++) { int ans = 0; for (int j = 0; j < n; j++) { int v = j; for (int l = 29; l >= 0; l--) { if (k[i] & (1 << l)) { v = nxt[l][v]; } } if (v == p % n) { ans++; } } answer(ans); } } #ifdef tabr int main() { ios::sync_with_stdio(false); cin.tie(0); return 0; } #endif
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...