Submission #345085

#TimeUsernameProblemLanguageResultExecution timeMemory
345085Kevin_Zhang_TWTropical Garden (IOI11_garden)C++17
69 / 100
5057 ms44336 KiB
#include "garden.h" #include "gardenlib.h" #include <bits/stdc++.h> using namespace std; using ll = long long; #define pb emplace_back #define AI(i) begin(i), end(i) template<class T> bool chmin(T &a, T b) { return b < a ? (a = b, true) : false; } template<class T> bool chmax(T &a, T b) { return a < b ? (a = b, true) : false; } #ifdef KEV #define DE(args...) kout("[ " + string(#args) + " ] = ", args) void kout() { cerr << endl; } template<class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ', kout(b...); } template<class T> void debug(T L, T R) { while (L != R) cerr << *L << " \n"[next(L) == R], ++L; } #else #define DE(...) 0 #define debug(...) 0 #endif const int MAX_N = 300010, MAX_K = 30; int nxt[MAX_K][MAX_N], n; // void answer(X) void count_routes(int N, int M, int P, int R[][2], int Q, int G[]) { { auto nxt0 = nxt[0]; fill(nxt0, nxt0 + N * 2, -1); vector<vector<int>> edge(N); for (int i = 0;i < M;++i) { int a = R[i][0], b = R[i][1]; edge[a].pb(b), edge[b].pb(a); } for (int i = 0;i < N;++i) { nxt0[i] = edge[i][0]; if (i == edge[ nxt0[i] ][0]) nxt0[i] += N; nxt0[i + N] = nxt0[i]; if (edge[i].size() > 1) { nxt0[i + N] = edge[i][1]; if (i == edge[ nxt0[i + N] ][0]) nxt0[i + N] += N; } DE(i, nxt0[i], nxt0[i + N]); } } for (int d = 1;d < MAX_K;++d) for (int i = 0;i < N+N;++i) nxt[d][i] = nxt[d-1][ nxt[d-1][i] ]; vector<int> cur(N + N); for (int i = 0;i < Q;++i) { DE(G[i]); iota(AI(cur), 0); for (int d = 0;d < MAX_K;++d) if (G[i]>>d&1) for (int &x : cur) x = nxt[d][x]; int res = 0; for (int j = 0;j < N;++j) if (cur[j] % N == P) ++res; answer(res); } }

Compilation message (stderr)

garden.cpp: In function 'void count_routes(int, int, int, int (*)[2], int, int*)':
garden.cpp:17:17: warning: statement has no effect [-Wunused-value]
   17 | #define DE(...) 0
      |                 ^
garden.cpp:41:4: note: in expansion of macro 'DE'
   41 |    DE(i, nxt0[i], nxt0[i + N]);
      |    ^~
garden.cpp:17:17: warning: statement has no effect [-Wunused-value]
   17 | #define DE(...) 0
      |                 ^
garden.cpp:52:3: note: in expansion of macro 'DE'
   52 |   DE(G[i]);
      |   ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...