제출 #430365

#제출 시각아이디문제언어결과실행 시간메모리
430365Keshi기지국 (IOI20_stations)C++17
67.23 / 100
1480 ms940 KiB
//In the name of God #include<bits/stdc++.h> #include "stations.h" using namespace std; typedef int ll; typedef pair<ll, ll> pll; const ll maxn = 1100; const ll mod = 1e9 + 7; const ll inf = 1e9; #define Mp make_pair #define F first #define S second #define pb push_back #define all(x) (x).begin(), (x).end() #define Sz(x) ll((x).size()) ll t, st[maxn], ft[maxn], h[maxn]; vector<ll> g[maxn]; void dfs(ll v, ll p){ st[v] = t++; for(ll u : g[v]){ if(u != p){ h[u] = h[v] + 1; dfs(u, v); } } ft[v] = t++; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { for(ll i = 0; i < n; i++){ g[i].clear(); } vector<int> labels(n); for(ll i = 0; i < n - 1; i++){ g[u[i]].pb(v[i]); g[v[i]].pb(u[i]); } dfs(0, 0); for (int i = 0; i < n; i++) { if(h[i] & 1) labels[i] = ft[i]; else labels[i] = st[i]; } return labels; } int find_next_station(int s, int t, vector<int> c){ if(Sz(c) == 1) return c[0]; sort(all(c)); if(s < c[0]){ ll ls = s + 1; for(ll i = 0; i < Sz(c) - 1; i++){ if(ls <= t && t <= c[i]) return c[i]; ls = c[i] + 1; } return c.back(); } ll ls = s - 1; for(ll i = Sz(c) - 1; i > 0; i--){ if(c[i] <= t && t <= ls) return c[i]; ls = c[i] - 1; } 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...