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 "grader.cpp"
#include <bits/stdc++.h>
using namespace std;
#define lol long long
#define pii pair<int,int>
#define OK puts("OK");
#define NO puts("NO");
#define YES puts("YES");
#define fr first
#define sc second
#define ret return
#define scanl(a) scanf("%lld",&a);
#define scanll(a,b) scanf("%lld %lld",&a, &b);
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
#define scan1(a) scanf("%d",&a);
#define scan2(a,b) scanf("%d %d",&a, &b);
#define scan3(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin()Ñ,s.rend()
#define pb push_back
#define sz(v) (int)v.size()
#define endi puts("");
#define eps 1e-12
const int INF=1e9+7;
int n,p,ans=0,f,k;
vector <int> g[100001];
void dfs(int nd,int pr){
if (k < 0)ret;
k--;
if (k == 0){
if (nd == p)
ans++;
ret;
}
else {
if (g[nd].size() == 1){
dfs(g[nd][0],nd);
ret;
}
else if (g[nd].size() == 2){
if (g[nd][0] != pr){
dfs(g[nd][0],nd);
k--;
}
else if (g[nd][1] != pr){
dfs(g[nd][1],nd);
k--;
}
}
}
}
void count_routes(int N, int M, int P, int R[][2], int Q, int G[])
{
int i,j;
for (i=0;i<M;++i){
if (g[R[i][0]].size() < 2){
g[R[i][0]].pb(R[i][1]);
}
if (g[R[i][1]].size() < 2){
g[R[i][1]].pb(R[i][0]);
}
}
p = P;
for (j=0;j<Q;++j){
for (i=0;i<N;++i){
k=G[j]+1;
dfs(i,-1);
f=0;
}
answer(ans);
ans=0;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |