#include "garden.h"
#include "gardenlib.h"
#include "bits/stdc++.h"
using namespace std;
const int nx=1e3+5;
int v[nx], vs[nx], ans;
void count_routes(int N, int M, int P, int R[][2], int Q, int G[])
{
for (int i=0; i<N; i++) v[i]=vs[i]=-1;
for (int i=0; i<M; i++)
{
if (v[R[i][0]]==-1) v[R[i][0]]=R[i][1];
else if (vs[R[i][0]]==-1) vs[R[i][0]]=R[i][1];
if (v[R[i][1]]==-1) v[R[i][1]]=R[i][0];
else if (vs[R[i][1]]==-1) vs[R[i][1]]=R[i][0];
}
for (int i=0; i<N; i++) if (vs[i]==-1) vs[i]=v[i];
for (int i=0; i<N; i++)
{
int l=i, f=1, k=G[0];
while (k--)
{
if (f)
{
if (v[v[l]]==l) f=0;
else f=1;
l=v[l];
}
else
{
if (v[vs[l]]==l) f=0;
else f=1;
l=vs[l];
}
}
if (l==P) ans++;
}
answer(ans);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
444 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
444 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
2 ms |
348 KB |
Output is correct |
11 |
Incorrect |
692 ms |
2880 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
444 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
2 ms |
348 KB |
Output is correct |
11 |
Incorrect |
692 ms |
2880 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |