# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
709928 | raysh07 | Stations (IOI20_stations) | C++17 | 3037 ms | 2097152 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
#define INF (int)1e9
const int N = 1005;
int timer = 0;
int tin[N], tout[N];
vector <int> adj[N];
int ans[N];
void dfs(int u, int par = -1, int dist = 0){
tin[u] = ++timer;
for (int v: adj[u]){
if (v != par){
dfs(v, u, dist + 1);
}
}
tout[u] = ++timer;
if (dist & 1) ans[u] = tout[u];
else ans[u] = tin[u];
}
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);
int ptr = -1;
set <int> st; map <int, int> comp;
for (int i=0; i<n; i++) st.insert(ans[i]);
for (auto x: st) comp[x] = ++ptr;
assert(st.size() == n);
vector <int> lab;
for (int i=0; i<n; i++) lab.push_back(comp[ans[i]]);
return lab;
}
int find_next_station(int s, int t, vector<int> c) {
if (s==0){
//root
for (auto x: c){
if (x >= t) return x;
}
assert(false);
}
if (c.size() == 1) return c[0];
//either s is tin time of u, in which case, rest all are tout times
//tout of everything else shud be strictly larger
//else s is tout time of u, in which case rest all are tin times
//tin of everything else shud be strictly smaller
if (s > c[0]){
//this is tout time
//rest all are tin time
//if t is not in range [c[1], s] its not in subtree
if (t < c[1] || t > s) return c[0];
c.push_back(INF);
for (int i=2; i<c.size(); i++){
if (c[i] > t) return c[i-1];
}
}
else {
assert(s < c[0]);
//now range is [s, c[c.size() - 2]
if (t < s || t > c[c.size() - 2]) return c.back();
for (int i=0; i<c.size() - 1; i++){
if (t <= c[i]) return c[i];
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |