#include "garden.h"
#include "gardenlib.h"
#include <bits/stdc++.h>
using namespace std;
int ans = 0;
vector<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], k - 1, P, u);
else{
for(auto v:vc[u]){
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(R[i][1]), vc[R[i][1]].emplace_back(R[i][0]);
for(int i = 0; i < N; ++i) dfs(i, G[0], P, -1);
answer(ans);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
6736 KB |
Output is correct |
2 |
Correct |
3 ms |
6736 KB |
Output is correct |
3 |
Correct |
3 ms |
6784 KB |
Output is correct |
4 |
Correct |
2 ms |
6736 KB |
Output is correct |
5 |
Correct |
2 ms |
6736 KB |
Output is correct |
6 |
Correct |
3 ms |
6736 KB |
Output is correct |
7 |
Correct |
2 ms |
6736 KB |
Output is correct |
8 |
Correct |
2 ms |
6736 KB |
Output is correct |
9 |
Correct |
3 ms |
6736 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
6736 KB |
Output is correct |
2 |
Correct |
3 ms |
6736 KB |
Output is correct |
3 |
Correct |
3 ms |
6784 KB |
Output is correct |
4 |
Correct |
2 ms |
6736 KB |
Output is correct |
5 |
Correct |
2 ms |
6736 KB |
Output is correct |
6 |
Correct |
3 ms |
6736 KB |
Output is correct |
7 |
Correct |
2 ms |
6736 KB |
Output is correct |
8 |
Correct |
2 ms |
6736 KB |
Output is correct |
9 |
Correct |
3 ms |
6736 KB |
Output is correct |
10 |
Correct |
6 ms |
6736 KB |
Output is correct |
11 |
Execution timed out |
5084 ms |
7292 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
6736 KB |
Output is correct |
2 |
Correct |
3 ms |
6736 KB |
Output is correct |
3 |
Correct |
3 ms |
6784 KB |
Output is correct |
4 |
Correct |
2 ms |
6736 KB |
Output is correct |
5 |
Correct |
2 ms |
6736 KB |
Output is correct |
6 |
Correct |
3 ms |
6736 KB |
Output is correct |
7 |
Correct |
2 ms |
6736 KB |
Output is correct |
8 |
Correct |
2 ms |
6736 KB |
Output is correct |
9 |
Correct |
3 ms |
6736 KB |
Output is correct |
10 |
Correct |
6 ms |
6736 KB |
Output is correct |
11 |
Execution timed out |
5084 ms |
7292 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |