제출 #830740

#제출 시각아이디문제언어결과실행 시간메모리
830740pavement기지국 (IOI20_stations)C++17
13 / 100
784 ms836 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; #define pb push_back int idx; vector<int> dep, in, out; vector<vector<int> > adj; void dfs(int u, int e = -1) { in[u] = idx++; for (auto v : adj[u]) if (v != e) { dep[v] = dep[u] + 1; dfs(v, u); } out[u] = idx++; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { dep = in = out = vector<int>(n); adj = vector<vector<int> >(n); for (int i = 0; i < (int)u.size(); i++) { adj[u[i]].pb(v[i]); adj[v[i]].pb(u[i]); } dfs(0); vector<int> lab(n), vals(n); for (int i = 0; i < n; i++) { lab[i] = (dep[i] % 2 == 0 ? in[i] : out[i]); vals[i] = lab[i]; } sort(vals.begin(), vals.end()); assert(unique(vals.begin(), vals.end()) == vals.end()); for (int i = 0; i < n; i++) { lab[i] = lower_bound(vals.begin(), vals.end(), lab[i]) - vals.begin(); } for (int i = 0; i < n; i++) { adj[i].clear(); } dep.clear(); in.clear(); out.clear(); idx = 0; return lab; } int find_next_station(int s, int t, vector<int> c) { if (s == 0) { for (int i = 0; i < (int)c.size(); i++) { if (t <= c[i]) { return c[i]; } } assert(0); } else if (s < *min_element(c.begin(), c.end())) { for (int i = 0; i + 1 < (int)c.size(); i++) { if (s < t && t <= c[i]) { return c[i]; } } return c.back(); } else { for (int i = 1; i < (int)c.size(); i++) { if (((i + 1 == (int)c.size() && t < s) || c[i + 1] > t) && t >= c[i]) { return c[i]; } } return c[0]; } }
#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...