Submission #347860

#TimeUsernameProblemLanguageResultExecution timeMemory
347860beksultan04Tropical Garden (IOI11_garden)C++14
0 / 100
4 ms5228 KiB
#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 p,ans=0,f,k,up[300001][31]; vector <int> g[200001]; 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]); } for (i=0;i<2*N;++i)up[i][0]=-1; for (int pr=0;pr<N;++pr){ j=0; for (int nd : g[pr]){ if (g[nd][0] == pr && g[nd].size() == 2){ up[pr+j*N][0]=nd+N; } else { up[pr+j*N][0]=nd; } j++; } } for (i=1;i<31;++i){ for (j=0;j<2*N;++j){ if(~up[j][0])up[j][i] = up[up[j][i-1]][i-1]; else up[j][i] = -1; } } for (j=0;j<Q;++j){ for (i=0;i<2*N;++i){ int v = i; k = G[j]-1; for (int pw = 30;pw>=0;--pw){ if (k&(1<<pw)){ k-=(1<<pw); v = up[v][pw]; } } if (v == P || v == P+N)ans++; } answer(ans); ans=0; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...