#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(u == P && k == 0){
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
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 time |
Memory |
Grader output |
1 |
Execution timed out |
5048 ms |
6736 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5048 ms |
6736 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5048 ms |
6736 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |