Submission #80001

#TimeUsernameProblemLanguageResultExecution timeMemory
80001Just_Solve_The_ProblemTropical Garden (IOI11_garden)C++11
49 / 100
5042 ms4776 KiB
#include "garden.h" #include "gardenlib.h" //#include "grader.cpp" #include <bits/stdc++.h> using namespace std; const int NN = (int)150007; int deg[NN]; int n, m, p, q; vector < int > gr[NN]; int K; int solve(int v) { int k = K; int pr = v; while (k--) { if (gr[v][0] == pr) { if (gr[v].size() > 1) { pr = v; v = gr[v][1]; } else { pr = v; v = gr[v][0]; } } else { pr = v; v = gr[v][0]; } } return v == p; } void count_routes(int _N, int _M, int _P, int R[][2], int _Q, int G[]) { n = _N; m = _M; p = _P; for (int i = 0; i < m; i++) { if (deg[R[i][0]] != 2) { gr[R[i][0]].push_back(R[i][1]); deg[R[i][0]]++; } if (deg[R[i][1]] != 2) { gr[R[i][1]].push_back(R[i][0]); deg[R[i][1]]++; } } for (int j = 0; j < _Q; j++) { int ans = 0; K = G[j]; for (int i = 0; i < n; i++) { ans += solve(i); } answer(ans); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...