#include "garden.h"
#include "gardenlib.h"
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
ifstream fin("f.in");
ofstream fout("f.out");
vector<vector<int>> graf;
int curr, gres[2005], d[150005], maxg, p;
unordered_map<int, int> gg;
int dfs(int node, int tata, int pas)
{
if(pas <= maxg)
{
if(node == p && gg[pas])
gres[gg[pas] - 1]++;
if(graf[node].size() == 1)
dfs(graf[node][0], node, pas + 1);
else
{
if(graf[node][0] == tata)
dfs(graf[node][1], node, pas + 1);
else
dfs(graf[node][0], node, pas + 1);
}
}
}
void count_routes(int N, int M, int P, int R[][2], int Q, int G[])
{
p = P;
graf.resize(N + 1);
for(int i = 0; i < M; i++)
{
if(graf[R[i][0]].size() < 2)
graf[R[i][0]].push_back(R[i][1]);
if(graf[R[i][1]].size() < 2)
graf[R[i][1]].push_back(R[i][0]);
}
for(int i = 0; i < Q; i++)
{
maxg = max(maxg, G[i]);
gg[G[i]] = i + 1;
}
for(int i = 0; i < N; i++)
{
dfs(i, -1, 0);
}
for(int i = 0; i < Q; i++)
answer(gres[i]);
}
Compilation message
garden.cpp: In function 'int dfs(int, int, int)':
garden.cpp:33:1: warning: no return statement in function returning non-void [-Wreturn-type]
33 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
168 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
168 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
168 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |