Submission #1105209

#TimeUsernameProblemLanguageResultExecution timeMemory
1105209jadai007Tropical Garden (IOI11_garden)C++17
49 / 100
5071 ms7504 KiB
#include "garden.h" #include "gardenlib.h" #include <bits/stdc++.h> using namespace std; int ans = 0; vector<pair<int, int>> vc[200200]; void dfs(int u, int k, int P, int par){ if(k == 0){ if(u == P) ans++; return; } if(vc[u].size() == 1) dfs(vc[u][0].second, k - 1, P, u); else{ for(auto x:vc[u]){ int w = x.first, v = x.second; if(v == par) continue; dfs(v, k - 1, P, u); break; } } } void count_routes(int N, int M, int P, int R[][2], int Q, int G[]){ for(int i = 0; i < M; ++i) vc[R[i][0]].emplace_back(i, R[i][1]), vc[R[i][1]].emplace_back(i, R[i][0]); for(int i = 0; i < N; ++i) sort(vc[i].begin(), vc[i].end()); for(int i = 0; i < N; ++i) dfs(i, G[0], P, -1); answer(ans); }

Compilation message (stderr)

garden.cpp: In function 'void dfs(int, int, int, int)':
garden.cpp:18:17: warning: unused variable 'w' [-Wunused-variable]
   18 |             int w = x.first, v = x.second;
      |                 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...