#include "garden.h"
#include "gardenlib.h"
#include<bits/stdc++.h>
#define mp make_pair
using namespace std;
int counter = 0;
int tar;
vector< vector<pair<int,int> > > adj;
void DFSVisit(int n, int hak, int road);
void count_routes(int N, int M, int P, int R[][2], int Q, int G[])
{
// printf("hebele\n");
tar = P;
adj.resize(N);
// printf("hebele\n");
for(int i=0; i<N; i++) {
int c1 = R[i][0];
int c2 = R[i][1];
// printf("hebele\n");
adj[c1].push_back(mp(c2,i));
adj[c2].push_back(mp(c1,i));
}
// printf("hebele\n");
for(int i=0; i<N; i++) DFSVisit(adj[i][0].first, G[0]-1, adj[i][0].second );
answer(counter);
}
void DFSVisit(int n, int hak, int road) {
// printf("%d\n", hak);
if(hak==0) {
if (n==tar) counter++;
return;
}
if(adj[n].size()==1) DFSVisit(adj[n][0].first, hak-1, road);
else if(adj[n][0].second != road) DFSVisit(adj[n][0].first, hak-1, adj[n][0].second);
else DFSVisit(adj[n][1].first, hak-1, adj[n][1].second);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
320 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
380 KB |
Output is correct |
4 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
320 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
380 KB |
Output is correct |
4 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
320 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
380 KB |
Output is correct |
4 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |