# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
399069 | Antekb | 기지국 (IOI20_stations) | C++14 | 1202 ms | 804 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
const int N=1005;
int pre[N], post[N], d[N];
vector<int> E[N];
int wsk=1;
void dfs(int v, int p){
//cout<<v<<" "<<p<<" "<<wsk<<endl;
pre[v]=wsk++;
for(int u:E[v]){
if(u!=p){
assert(pre[u]==0);
d[u]=d[v]+1;
dfs(u, v);
}
}
post[v]=wsk++;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
for(int i=0; i<n; i++){
pre[i]=post[i]=d[i]=0;
E[i].clear();
}
for(int i=0; i<n-1; i++){
E[u[i]].push_back(v[i]);
E[v[i]].push_back(u[i]);
}
std::vector<int> labels(n);
wsk=1;
d[0]=0;
dfs(0, -1);
for (int i = 0; i < n; i++) {
if(d[i]&1)labels[i] = pre[i];
else labels[i]=post[i];
//cout<<i<<" "<<labels[i]<<"\n";
}
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
sort(c.begin(), c.end());
bool ma=1;
for(int i:c){
if(i>s)ma=0;
}
if(ma){
if(t>=s)return c[0];
for(int i=c.size()-1; i>=0; i--){
if(c[i]<=t)return c[i];
}
return c[0];
}
else{
//reverse(c.begin(), c.end());
if(t<s)return c.back();
for(int i=0; i<c.size(); i++){
if(c[i]>=t)return c[i];
}
return c.back();
}
}
컴파일 시 표준 에러 (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... |