# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
565167 | Ronin13 | Stations (IOI20_stations) | C++14 | 855 ms | 828 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "stations.h"
#include <vector>
#include <bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
#define ull unsigned ll
using namespace std;
const int inf = 1e9 + 1;
const ll linf = 1e18 + 1;
const int NMAX = 1001;
vector <vector <int> > g (NMAX);
vector <int> col(NMAX);
int timer = 0;
vector <int> t_in(NMAX);
vector <int> t_out(NMAX);
void dfs(int v, int e = -1){
t_in[v] = timer++;
for(int to : g[v]){
if(to == e) continue;
col[to] = 1 ^ col[v];
dfs(to, v);
}
t_out[v] = timer++;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
for(int v = 0; v < n; v++){
t_in[v] = t_out[v] = col[v] = 0;
g[v].clear();
timer = 0;
}
std::vector<int> labels(n);
for(int i = 0; i < n - 1; i++){
int uu = u[i], vv = v[i];
g[uu].pb(vv);
g[vv].pb(uu);
}
dfs(0);
vector <pii> vec;
for(int i = 0; i < n; i++){
if(col[i] == 0) vec.pb({t_in[i], i});
else vec.pb({t_out[i], i});
}
sort(vec.begin(), vec.end());
int ind = 0;
for(auto to : vec){
int x = to.f, y = to.s;
labels[y] = ind++;
}
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
bool bl = false;
if(c[0] > s) bl = true;
if(bl){
sort(c.begin(), c.end());
if(t >= c.back()) return c.back();
//if(c[0] >= t ) return c.back();
if(t < s) return c.back();
for(int i = c.size() - 1 ; i >= 0; i--){
if(c[i] < t) return c[i + 1];
}
return c[0];
}
else{
sort(c.begin(), c.end());
/*for(int to : c){
cout << to << " ";
}*/
if(t > s) return c[0];
if(t <= c[0]) return c[0];
//if(c.back() <= t) return c[0];
for(int i = 0; i < c.size(); i++){
if(c[i] > t) return c[i - 1];
}
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... |