#include <bits/stdc++.h>
#define s second
#define f first
#include "garden.h"
#include "gardenlib.h"
using namespace std;
const int N = 1005;
int K,P,ans=0;
vector<pair<int,int> > A[N];
void dfs(int u,int k, int par = -1) {
if(k==K) {
// cout << "can\n";
if(u==P)ans++;
return;
}
if(A[u].size() == 1) dfs(A[u][0].s,k+1,u);
else for(auto [w,nxt] : A[u]) if(nxt!=par) {
dfs(nxt,k+1,u);
break;
}
}
void count_routes(int n, int m, int pp, int R[][2], int Q, int G[])
{
K = G[0];
P = pp;
for(int i = 0;i<m;i++) {
A[R[i][0]].push_back({i,R[i][1]});
A[R[i][1]].push_back({i,R[i][0]});
}
for(int i = 0;i<n;i++) sort(A[i].begin(),A[i].end());
for(int i = 0;i<n;i++){
// cout << "doing " << i << "\n";
dfs(i,0);
}
answer(ans);
}
/*
/usr/bin/g++ -DEVAL -std=gnu++11 -O2 -pipe -s -o garden grader.cpp garden.cpp
./garden
6 6 0
1 2
0 1
0 3
3 4
4 5
1 5
1
3
2
5 5 2
1 0
1 2
3 2
1 3
4 2
2
3 1
1 2
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
2 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
3 ms |
848 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
2 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
3 ms |
848 KB |
Output is correct |
10 |
Correct |
4 ms |
336 KB |
Output is correct |
11 |
Runtime error |
7 ms |
5352 KB |
Execution killed with signal 11 |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
2 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
3 ms |
848 KB |
Output is correct |
10 |
Correct |
4 ms |
336 KB |
Output is correct |
11 |
Runtime error |
7 ms |
5352 KB |
Execution killed with signal 11 |
12 |
Halted |
0 ms |
0 KB |
- |