제출 #772448

#제출 시각아이디문제언어결과실행 시간메모리
772448SanguineChameleon기지국 (IOI20_stations)C++17
0 / 100
3027 ms2097152 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; const int maxn = 1e3 + 20; vector<int> adj[maxn]; int tin[maxn]; int tout[maxn]; int dfs_t = -1; void dfs(int u, int p) { tin[u] = ++dfs_t; for (auto v: adj[u]) { if (v != p) { dfs(v, u); } } tout[u] = dfs_t; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { for (int i = 0; i < n - 1; i++) { adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); } dfs(0, -1); vector<int> labels(n); for (int i = 0; i < n; i++) { labels[i] = tin[i] * 1000 + tout[i]; } return labels; } int find_next_station(int s, int t, vector<int> c) { int tin_s = s / 1000; int tout_s = s % 1000; int tin_t = t / 1000; int tout_t = t % 1000; int par = -1; for (auto u: c) { int tin_u = u / 1000; int tout_u = u % 1000; if (tin_u <= tin_s && tout_s <= tout_u) { par = u; } else if (tin_u <= tin_t && tout_t <= tout_u) { return u; } } return par; }
#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...