#include "garden.h"
#include "gardenlib.h"
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int MxN = 1005;
int n, m, p, q, g, r[MxN][2];
ll ans;
vector<pii> v[MxN];
void dfs (int cur, int par, int dist) {
if (dist == g && cur == p) return void(ans++);
if (dist >= g) return;
if (v[cur].size() == 1) {
auto [x, y] = v[cur][0];
dfs(y, cur, dist + 1);
} else {
for (auto &[x, y]: v[cur]) {
if (par != y) {
dfs(y, cur, dist + 1); break;
}
}
}
}
void count_routes(int N, int M, int P, int R[][2], int Q, int G[]){
n = N; m = M; p = P; q = Q; g = G[0];
for (int i = 0; i < m; i++) {
r[i][0] = R[i][0]; r[i][1] = R[i][1];
v[r[i][0]].emplace_back(i, r[i][1]);
v[r[i][1]].emplace_back(i, r[i][0]);
}
for (int i = 0; i < n; i++) sort(v[i].begin(), v[i].end());
for (int i = 0; i < n; i++) dfs(i, -1, 0);
answer(ans);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Incorrect |
1 ms |
508 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Incorrect |
1 ms |
508 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Incorrect |
1 ms |
508 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |