제출 #1062776

#제출 시각아이디문제언어결과실행 시간메모리
1062776Boas열대 식물원 (Tropical Garden) (IOI11_garden)C++17
49 / 100
5095 ms4188 KiB
#include "gardenlib.h" #include <bits/stdc++.h> using namespace std; typedef pair<int, int> ii; typedef tuple<int, int, int> iii; typedef vector<int> vi; typedef vector<ii> vii; typedef vector<vi> vvi; typedef vector<vii> vvii; #define loop(x, i) for (int i = 0; i < x; i++) #define pb push_back void count_routes(int N, int M, int P, int R[][2], int Q, int G[]) { vvii adj(N); loop(M, i) { adj[R[i][0]].pb({i, R[i][1]}); adj[R[i][1]].pb({i, R[i][0]}); } for (int i = 0; i < Q; i++) { int K = G[i]; int cnt = 0; loop(N, start) { int prevTrail = -1; int cur = start; loop(K, i) { if (adj[cur].size() == 1 || adj[cur][0].first != prevTrail) { prevTrail = adj[cur][0].first; cur = adj[cur][0].second; } else { prevTrail = adj[cur][1].first; cur = adj[cur][1].second; } } if (cur == P) cnt++; } answer(cnt); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...