Submission #1112749

#TimeUsernameProblemLanguageResultExecution timeMemory
1112749PagodePaivaTropical Garden (IOI11_garden)C++17
49 / 100
7 ms4944 KiB
#include<bits/stdc++.h> #include "garden.h" #include "gardenlib.h" using namespace std; const int N = 1010; vector <array <int, 2>> g[N]; void count_routes(int n, int m, int P, int r[][2], int Q, int G[]){ for(int i = 0;i < m;i++){ g[r[i][0]].push_back({i, r[i][1]}); g[r[i][1]].push_back({i, r[i][0]}); } for(int i = 0;i < n;i++){ sort(g[i].begin(), g[i].end()); } for(int i =0;i < Q;i++){ int res = 0; for(int j = 0;j < n;j++){ int v = j, peso = -1; int k = G[i]; while(k > 0){ if(g[v].empty())k--; else{ if(g[v][0][0] != peso){ peso = g[v][0][0]; v = g[v][0][1]; } else{ if(g[v].size() == 1) v = g[v][0][1]; else{ peso = g[v][1][0]; v = g[v][1][1]; } } k--; } } if(v == P) res++; } answer(res); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...