Submission #1104552

#TimeUsernameProblemLanguageResultExecution timeMemory
1104552NinedesuTropical Garden (IOI11_garden)C++14
49 / 100
5087 ms5504 KiB
#include "garden.h" #include "gardenlib.h" #include<bits/stdc++.h> using namespace std; int ans; vector<int>adj[100001]; void dfs(int u,int p,int P,int G,int dis){ if(dis==G){ if(u==P)ans++; return ; } if(adj[u][0]!=p||adj[u].size()==1)dfs(adj[u][0],u,P,G,dis+1); else dfs(adj[u][1],u,P,G,dis+1); } void count_routes(int N, int M, int P, int R[][2], int Q, int G[]) { for(int i=0; i<M; i++){ adj[R[i][0]].push_back(R[i][1]); adj[R[i][1]].push_back(R[i][0]); } for(int i=0; i<Q; i++){ ans=0; for(int u=0; u<N; u++){ dfs(u,-1,P,G[i],0); } answer(ans); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...