#include "garden.h"
#include "gardenlib.h"
#include <bits/stdc++.h>
using namespace std;
//answer(N) -- query
int n;
int INF = 1e9;
int p;
vector<vector<int>> adjlist;
bool works(int node, bool blocked, int cnt){
if (cnt==0){
if (node==p){
return true;
}
return false;
}
int next = adjlist[node][0];
if (adjlist[node].size()>1&&blocked){
next = adjlist[node][1];
}
bool isBlocked = adjlist[next][0]==node;
return works(next,isBlocked,cnt-1);
}
void count_routes(int N, int M, int P, int R[][2], int Q, int G[]) {
n=N;p=P;
adjlist.resize(n);
for (int i = 0; i<M; i++){
adjlist[R[i][0]].push_back(R[i][1]);
adjlist[R[i][1]].push_back(R[i][0]);
}
int v = 0;
for (int i = 0; i<n; i++){
v+=works(i,false,G[0]);
}
answer(v);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
640 KB |
Output is correct |
10 |
Correct |
7 ms |
384 KB |
Output is correct |
11 |
Execution timed out |
5047 ms |
1920 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
640 KB |
Output is correct |
10 |
Correct |
7 ms |
384 KB |
Output is correct |
11 |
Execution timed out |
5047 ms |
1920 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |