이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |