#include "garden.h"
#include "gardenlib.h"
#include<bits/stdc++.h>
using namespace std;
int ans;
vector<int>adj[100001];
void dfs(int u,int p,int P,int G,int dis){
if(dis==G){
if(u==P)ans++;
return ;
}
if(adj[u][0]!=p||adj[u].size()==1)dfs(adj[u][0],u,P,G,dis+1);
else dfs(adj[u][1],u,P,G,dis+1);
}
void count_routes(int N, int M, int P, int R[][2], int Q, int G[])
{
for(int i=0; i<M; i++){
adj[R[i][0]].push_back(R[i][1]);
adj[R[i][1]].push_back(R[i][0]);
}
for(int i=0; i<Q; i++){
ans=0;
for(int u=0; u<N; u++){
dfs(u,-1,P,G[i],0);
}
answer(ans);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4688 KB |
Output is correct |
2 |
Correct |
2 ms |
4860 KB |
Output is correct |
3 |
Correct |
2 ms |
4856 KB |
Output is correct |
4 |
Correct |
1 ms |
4700 KB |
Output is correct |
5 |
Correct |
1 ms |
4688 KB |
Output is correct |
6 |
Correct |
3 ms |
4688 KB |
Output is correct |
7 |
Correct |
2 ms |
4688 KB |
Output is correct |
8 |
Correct |
2 ms |
4688 KB |
Output is correct |
9 |
Correct |
4 ms |
4688 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4688 KB |
Output is correct |
2 |
Correct |
2 ms |
4860 KB |
Output is correct |
3 |
Correct |
2 ms |
4856 KB |
Output is correct |
4 |
Correct |
1 ms |
4700 KB |
Output is correct |
5 |
Correct |
1 ms |
4688 KB |
Output is correct |
6 |
Correct |
3 ms |
4688 KB |
Output is correct |
7 |
Correct |
2 ms |
4688 KB |
Output is correct |
8 |
Correct |
2 ms |
4688 KB |
Output is correct |
9 |
Correct |
4 ms |
4688 KB |
Output is correct |
10 |
Correct |
5 ms |
4856 KB |
Output is correct |
11 |
Execution timed out |
5087 ms |
5504 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4688 KB |
Output is correct |
2 |
Correct |
2 ms |
4860 KB |
Output is correct |
3 |
Correct |
2 ms |
4856 KB |
Output is correct |
4 |
Correct |
1 ms |
4700 KB |
Output is correct |
5 |
Correct |
1 ms |
4688 KB |
Output is correct |
6 |
Correct |
3 ms |
4688 KB |
Output is correct |
7 |
Correct |
2 ms |
4688 KB |
Output is correct |
8 |
Correct |
2 ms |
4688 KB |
Output is correct |
9 |
Correct |
4 ms |
4688 KB |
Output is correct |
10 |
Correct |
5 ms |
4856 KB |
Output is correct |
11 |
Execution timed out |
5087 ms |
5504 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |