Submission #1104543

#TimeUsernameProblemLanguageResultExecution timeMemory
1104543NxmkxingTropical Garden (IOI11_garden)C++14
0 / 100
2 ms4856 KiB
#include "garden.h" #include "gardenlib.h" #include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; const int inf = 1e9; const int MxN = 1e5 + 10; int n, m, p, q, ans[MxN], g[MxN]; vector<pii> adj[MxN]; int cnt = -1; void dfs(int u, int pa, int i) { if (++cnt == g[i] && u == p) ans[i]++; for (auto [j, v] : adj[u]) { if (v == pa || cnt > g[i]) continue; dfs(v, u, i); if (++cnt == g[i] && u == p) ans[i]++; } } void count_routes(int N, int M, int P, int R[][2], int Q, int G[]) { n = N, m = M, p = P; for (int i = 0; i < M; i++) { int u = R[i][0]; int v = R[i][1]; adj[u].push_back({i, v}); adj[v].push_back({i, u}); } q = Q; for (int i = 0; i < Q; i++) { g[i] = G[i]; } for (int i = 0; i < n; i++) { sort(adj[i].begin(), adj[i].end()); } for (int i = 0; i < q; i++) { for (int j = 0; j < n; j++) { cnt = -1; dfs(j, -1, i); } } for (int i = 0; i < q; i++) { answer(ans[i]); } }

Compilation message (stderr)

garden.cpp: In function 'void dfs(int, int, int)':
garden.cpp:18:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   18 |   for (auto [j, v] : adj[u]) {
      |             ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...