Submission #85651

#TimeUsernameProblemLanguageResultExecution timeMemory
85651mirbek01Tropical Garden (IOI11_garden)C++17
49 / 100
5006 ms3704 KiB
#include "garden.h" #include "gardenlib.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 2; int k, ans, p, cnt[MAXN], used[MAXN]; vector <int> g[MAXN]; bool dfs(int v){ int c = k; int pr = v; while(c --){ if(g[v][0] == pr && g[v].size() > 1){ pr = v; v = g[v][1]; } else { pr = v; v = g[v][0]; } } return v == p; } void count_routes(int N, int M, int P, int R[][2], int Q, int G[]){ for(int i = 0; i < M; i ++){ int u = R[i][0], v = R[i][1]; if(g[u].size() < 2) g[u].push_back(v); if(g[v].size() < 2) g[v].push_back(u); } p = P; for(int i = 0; i < Q; i ++){ k = G[i]; ans = 0; for(int i = 0; i < N; i ++){ ans += dfs(i); } answer(ans); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...