# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1085024 | ZeroCool | 기지국 (IOI20_stations) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "stations.h"#include <vector>#include <bits/stdc++.h> using namespace std; const int N = 1000; vector<int> g[N];vector<int> A; int T = 0;void dfs(int x,int p, bool b){ if(b){ for(auto u: g[x]){ if(u == p)continue; dfs(u, x, !b); } A[x] = T++; }else{ A[x] = T++; for(auto u: g[x]){ if(u == p)continue; dfs(u, x, !b); } }} std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { T = 0; A.clear(); A.resize(n); for(int i = 0;i < n;i++)g[i].clear(); for(int i = 0;i < n- 1;i ++){ g[u[i]].push_back(v[i]); g[v[i]].push_back(u[i]); } dfs(0, 0,0 ); return A;} int find_next_station(int s, int t, std::vector<int> g) { if(g.size() == 1)return g.front(); sort(g.begin(), g.end()); if(s > g.front()){ if(t > s || t <= g.front())return g.front(); return *(upper_bound(g.begin(), g.end(), t) - 1); }else{ if(t < s | t >= g.back())return g.back(); return *lower_bound(g.begin(), g.end(), t); }}