# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
462524 | 2021-08-10T17:08:30 Z | wind_reaper | Stations (IOI20_stations) | C++17 | 0 ms | 0 KB |
#include "stations.h" #include <bits/stdc++.h> using namespace std; vector<int> g[1000], tin; int timer; void dfs(int u, int p, int d){ if(!d) tin[u] = timer++; for(int v : g[u]) if(v != p){ dfs(v, u, d ^ 1); } if(d) tin[u] = timer++; } vector<int> label(int n, int k, vector<int> u, vector<int> v){ for(int i = 0; i < n - 1; i++){ g[u[i]].push_back(v[i]); g[v[i]].push_back(u[i]); } tin.resize(n); dfs(tin, 0, -1, 0); return tin; } int find_next_station(int s, int t, vector<int> c){ int m = c.size(), i; if(s < c[0]){ for(i = 0; i < m - 1; i++) if(i == 0 ? s : c[i-1] < t && c[i] >= t) break; } else{ for(i = m - 1; i > 0; --i) if(i + 1 == m ? s : c[i+1] > t && c[i] <= t) break; } return c[i]; }