This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |