#include "garden.h"
#include "gardenlib.h"
#include <bits/stdc++.h>
using namespace std;
vector<pair<int,int> >adj[200000];
int lim,pur,cnt;
void dfs(int node,int from,int zai){
if(zai==lim){
if(pur==node)cnt++;
return;
}
if(adj[node].size()==1 && from!=-1){
dfs(adj[node][0].second,node,zai+1);
return;
}
if(adj[node][0].second!=from){
dfs(adj[node][0].second,node,zai+1);
}
else{
dfs(adj[node][1].second,node,zai+1);
}
}
void count_routes(int N, int M, int P, int R[][2], int Q, int G[])
{
pur=P;
lim=G[0];
for(int i=0;i<M;i++){
adj[R[i][0]].push_back({i,R[i][1]});
adj[R[i][1]].push_back({i,R[i][0]});
}
for(int i=0;i<N;i++){
sort(adj[i].begin(),adj[i].end());
}
for(int i=0;i<N;i++){
dfs(i,-1,0);
}
answer(cnt);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
4940 KB |
Output is correct |
2 |
Correct |
5 ms |
4940 KB |
Output is correct |
3 |
Correct |
5 ms |
4984 KB |
Output is correct |
4 |
Correct |
4 ms |
4940 KB |
Output is correct |
5 |
Correct |
4 ms |
4940 KB |
Output is correct |
6 |
Correct |
5 ms |
5108 KB |
Output is correct |
7 |
Correct |
5 ms |
5000 KB |
Output is correct |
8 |
Correct |
5 ms |
4940 KB |
Output is correct |
9 |
Correct |
8 ms |
5360 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
4940 KB |
Output is correct |
2 |
Correct |
5 ms |
4940 KB |
Output is correct |
3 |
Correct |
5 ms |
4984 KB |
Output is correct |
4 |
Correct |
4 ms |
4940 KB |
Output is correct |
5 |
Correct |
4 ms |
4940 KB |
Output is correct |
6 |
Correct |
5 ms |
5108 KB |
Output is correct |
7 |
Correct |
5 ms |
5000 KB |
Output is correct |
8 |
Correct |
5 ms |
4940 KB |
Output is correct |
9 |
Correct |
8 ms |
5360 KB |
Output is correct |
10 |
Correct |
10 ms |
4940 KB |
Output is correct |
11 |
Execution timed out |
5080 ms |
6184 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
4940 KB |
Output is correct |
2 |
Correct |
5 ms |
4940 KB |
Output is correct |
3 |
Correct |
5 ms |
4984 KB |
Output is correct |
4 |
Correct |
4 ms |
4940 KB |
Output is correct |
5 |
Correct |
4 ms |
4940 KB |
Output is correct |
6 |
Correct |
5 ms |
5108 KB |
Output is correct |
7 |
Correct |
5 ms |
5000 KB |
Output is correct |
8 |
Correct |
5 ms |
4940 KB |
Output is correct |
9 |
Correct |
8 ms |
5360 KB |
Output is correct |
10 |
Correct |
10 ms |
4940 KB |
Output is correct |
11 |
Execution timed out |
5080 ms |
6184 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |