#include <bits/stdc++.h>
#include "garden.h"
#include "gardenlib.h"
using namespace std;
const int maxn = 1e3+10;
const int maxm = 2e4+10;
typedef pair<int, int> pii;
int m, p, k;
vector<pii> grafo[maxn];
int dfs(int u, int ant, int qtd)
{
if (qtd > k) return -1;
if (qtd == k) return u;
for (auto pp: grafo[u])
{
int v = pp.first, e = pp.second;
if (grafo[u].size() > 1 && ant != -1 && abs(e-ant) == m) continue;
return dfs(v, e, qtd+1);
}
}
void count_routes(int N, int M, int P, int R[][2], int Q, int G[])
{
for (int i = 0; i < M; i++)
{
int u = R[i][0], v = R[i][1];
grafo[u].push_back({v, i}); grafo[v].push_back({u, i+M});
}
m = M, p = P, k = G[0];
int ans = 0;
for (int i = 0; i < N; i++)
if (dfs(i, -1, 0) == p)
ans++;
answer(ans);
}
Compilation message
garden.cpp: In function 'int dfs(int, int, int)':
garden.cpp:30:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
3 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
696 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
3 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
696 KB |
Output is correct |
10 |
Correct |
7 ms |
376 KB |
Output is correct |
11 |
Runtime error |
8 ms |
888 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
3 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
696 KB |
Output is correct |
10 |
Correct |
7 ms |
376 KB |
Output is correct |
11 |
Runtime error |
8 ms |
888 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
12 |
Halted |
0 ms |
0 KB |
- |