제출 #1000404

#제출 시각아이디문제언어결과실행 시간메모리
1000404kunzaZa183기지국 (IOI20_stations)C++17
0 / 100
573 ms692 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; const int maxn = 1000; vector<int> adjlist[maxn]; vector<int> labels; int ct = 0; void dfs(int cur, int par, int type) { if (type == 0) { // preorder labels[cur] = ct++; for (auto a : adjlist[cur]) if (a != par) dfs(a, cur, 1); } else { for (auto a : adjlist[cur]) if (a != par) dfs(a, cur, 0); labels[cur] = ct++; } } vector<int> label(int n, int k, vector<int> u, vector<int> v) { ct = 0; labels.clear(); for (int i = 0; i < n; i++) adjlist[i].clear(); for (int i = 0; i < n - 1; i++) adjlist[u[i]].push_back(v[i]), adjlist[v[i]].push_back(u[i]); labels.resize(n); dfs(0, 0, 0); return labels; } int find_next_station(int s, int t, vector<int> c) { sort(c.begin(), c.end()); if (s > c.front()) { if (t > s) return c.front(); return *(upper_bound(c.begin(), c.end(), t) - 1); } else { if (t < s) return c.back(); return *lower_bound(c.begin(), c.end(), t); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...