이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
vector<int> labels(n);
vector<vector<int>> adj(n);
for(int i=0;i<n-1;i++){
adj[u[i]].emplace_back(v[i]);
adj[v[i]].emplace_back(u[i]);
}
int tim = 0;
function<void(int,int,bool)> dfs = [&](int x,int p,bool type){
if(type)labels[x]=tim++;
for(int&i:adj[x])if(i!=p)dfs(i,x,!type);
if(!type)labels[x]=tim++;
};
dfs(0,-1,true);
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
if(s<c.front()){
// this is a min order
c.insert(c.begin(),s);
for(int i=1;i<c.size();i++){
if(c[i-1]<t and t<=c[i])return c[i];
}
return c.back();
} else {
// this is a max order
c.insert(c.end(),s);
for(int i=0;i<c.size()-1;i++){
if(c[i]<=t and t<c[i+1])return c[i];
}
return c.front();
}
}
컴파일 시 표준 에러 (stderr) 메시지
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:25:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
25 | for(int i=1;i<c.size();i++){
| ~^~~~~~~~~
stations.cpp:32:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | for(int i=0;i<c.size()-1;i++){
| ~^~~~~~~~~~~
# | 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... |