이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "stations.h"
#include <bits/stdc++.h>
#ifndef EVAL
#include "stub.cpp"
#endif
using ll = int;
using std::cin;
using std::cout;
using std::endl;
using std::vector;
using std::string;
using vi = vector<ll>;
using vii = vector<vi>;
using pii = std::pair<ll,ll>;
#define rep(i,j,k) for(ll i=ll(j); i<ll(k); i++)
#define REP(i,j,k) for(ll i=ll(j); i<=ll(k); i++)
#define per(i,j,k) for(ll i=ll(j); i>=ll(k); i--)
#define ln "\n"
#define pb emplace_back
#define mp std::make_pair
#define mtp std::make_tuple
#define all(a) a.begin(), a.end()
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
constexpr int mod = 1000;
int ord = 0;
vi left(n, -1), right(n, -1);
vii edge(n);
rep(i,0,n-1){
edge[u[i]].pb(v[i]);
edge[v[i]].pb(u[i]);
}
std::function<void(int)> dfs = [&](int now){
left[now] = ord++;
for(auto next: edge[now]){
if(left[next] == -1) dfs(next);
}
right[now] = ord;
};
dfs(0);
vi num(n);
rep(i,0,n) num[i] = left[i]*mod+right[i];
return num;
}
int find_next_station(int s, int t, std::vector<int> c) {
constexpr int mod = 1000;
int lt = t/mod, rt = t%mod;
int ls = s/mod, rs = s%mod;
if(ls <= lt && rt <= rs){
for(auto el: c){
int lc = el/mod, rc = el%mod;
if(lc <= ls && rs <= rc) continue;
if(lc <= lt && rt <= rc) return el;
}
}
else{
for(auto el: c){
int lc = el/mod, rc = el%mod;
if(lc <= ls && rs <= rc) return el;
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:66:1: warning: control reaches end of non-void function [-Wreturn-type]
66 | }
| ^
# | 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... |