# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
347795 | juggernaut | Tropical Garden (IOI11_garden) | C++14 | 22 ms | 42604 KiB |
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;
#ifdef EVAL
#else
#include"grader.cpp"
#endif
#define pb push_back
int go[300005][30];
vector<int>g[300005];
void count_routes(int N,int M,int P,int R[][2],int Q,int G[]){
memset(go,-1,sizeof(go));
for(int i=0;i<M;i++){
int x=R[i][0],y=R[i][1];
if(g[x].size()<2)g[x].pb(y);
if(g[y].size()<2)g[y].pb(x);
}
for(int i=0;i<N;i++)
for(int j=0;j<g[i].size();j++){
int to=g[i][j];
if(g[to][0]==i&&g[to].size()>1)go[i+j*N][0]=to+N;
else go[i+j*N][0]=to;
}
for(int j=1;j<30;j++)
for(int i=0;i<(N<<1);i++)
if(go[i][j]!=-1)go[i][j]=go[go[i][j-1]][j-1];
int cnt=0;
for(int i=0;i<N;i++){
int k=G[0],node=i;
for(int j=29;j>=0;j--)if(k>=(1<<j))node=go[node][j],k-=(1<<j);
cnt+=(node==P||node==P+N);
}
answer(cnt);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |