이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "stations.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
const int N = 1000;
vector<int> g[N];
vector<int> A;
int T = 0;
void dfs(int x,int p, bool b){
if(b){
for(auto u: g[x]){
if(u == p)continue;
dfs(u, x, !b);
}
A[x] = T++;
}else{
A[x] = T++;
for(auto u: g[x]){
if(u == p)continue;
dfs(u, x, !b);
}
}
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
T = 0;
A.clear();
A.resize(n);
for(int i = 0;i < n;i++)g[i].clear();
for(int i = 0;i < n- 1;i ++){
g[u[i]].push_back(v[i]);
g[v[i]].push_back(u[i]);
}
dfs(0, 0,0 );
return A;
}
int find_next_station(int s, int t, std::vector<int> g) {
if(g.size() == 1)return g.front();
sort(g.begin(), g.end());
if(s > g.front()){
if(t > s || t <= g.front())return g.front();
return *(upper_bound(g.begin(), g.end(), t) - 1);
}else{
if(t < s | t >= g.back())return g.back();
return *lower_bound(g.begin(), g.end(), t);
}
}
컴파일 시 표준 에러 (stderr) 메시지
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:49:8: warning: suggest parentheses around comparison in operand of '|' [-Wparentheses]
49 | if(t < s | t >= g.back())return g.back();
| ~~^~~
# | 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... |