Submission #1104541

#TimeUsernameProblemLanguageResultExecution timeMemory
1104541spycoderytTropical Garden (IOI11_garden)C++17
49 / 100
7 ms5352 KiB
#include <bits/stdc++.h> #define s second #define f first #include "garden.h" #include "gardenlib.h" using namespace std; const int N = 1005; int K,P,ans=0; vector<pair<int,int> > A[N]; void dfs(int u,int k, int par = -1) { if(k==K) { // cout << "can\n"; if(u==P)ans++; return; } if(A[u].size() == 1) dfs(A[u][0].s,k+1,u); else for(auto [w,nxt] : A[u]) if(nxt!=par) { dfs(nxt,k+1,u); break; } } void count_routes(int n, int m, int pp, int R[][2], int Q, int G[]) { K = G[0]; P = pp; for(int i = 0;i<m;i++) { A[R[i][0]].push_back({i,R[i][1]}); A[R[i][1]].push_back({i,R[i][0]}); } for(int i = 0;i<n;i++) sort(A[i].begin(),A[i].end()); for(int i = 0;i<n;i++){ // cout << "doing " << i << "\n"; dfs(i,0); } answer(ans); } /* /usr/bin/g++ -DEVAL -std=gnu++11 -O2 -pipe -s -o garden grader.cpp garden.cpp ./garden 6 6 0 1 2 0 1 0 3 3 4 4 5 1 5 1 3 2 5 5 2 1 0 1 2 3 2 1 3 4 2 2 3 1 1 2 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...