This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "garden.h"
#include "gardenlib.h"
#include<bits/stdc++.h>
using namespace std;
const int N = 1010;
vector<int> g[N];
bool check(int at,int e, int k) {
int p=at;
for(int i = 0;i<k;i++) {
if(g[at].size()>1 and g[at][0]==p) {
p=at;
at=g[at][1];
}
else {
p=at;
at=g[at][0];
}
}
if(at==e)return true;
return false;
}
void count_routes(int N, int M, int P, int R[][2], int Q, int G[]) {
for(int i = 0;i<M;i++) {
g[R[i][0]].push_back(R[i][1]);
g[R[i][1]].push_back(R[i][0]);
}
for(int i = 0;i<Q;i++) {
int ans=0;
for(int j = 0;j<N;j++) {
if(check(j, P, G[i])){
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... |