제출 #831155

#제출 시각아이디문제언어결과실행 시간메모리
831155Baytoro기지국 (IOI20_stations)C++17
0 / 100
884 ms10072 KiB
#include "stations.h" //#include "stub.cpp" #include <bits/stdc++.h> using namespace std; #define pb push_back const int N=2e5+5; vector<int> g[N]; int tin[N],tout[N],D[N],cnt=0; void dfs(int x, int p){ tin[x]=cnt++; for(auto it: g[x]){ if(it==p) continue; D[it]=D[x]+1; dfs(it,x); } tout[x]=cnt++; } vector<int> label(int n, int k,vector<int> u, vector<int> v) { for(int i=0;i<n;i++) g[i].clear(); cnt=0; for(int i=0;i<n-1;i++){ g[u[i]].pb(v[i]); g[v[i]].pb(u[i]); } dfs(0,0); vector<int> ans(n); for(int i=0;i<n;i++){ if(D[i]%2) ans[i]=tout[i]; else ans[i]=tin[i]; } return ans; } int find_next_station(int s, int t, vector<int> c) { if(c.size()==1) return c[0]; int a=0; if(c.back()>=s){ if(t>s || t<c[0]) return c[0]; a=1; } else{ if(t<s || t>c.back()) return c.back(); } return c[lower_bound(c.begin(),c.end(),t+a)-c.begin()-a]; }
#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...