이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "stations.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=1e3+7;
vector<int>V[LIM];
int T[LIM], odw[LIM], l;
void DFS(int x, int v) {
odw[x]=1;
if(v%2==0) {
T[x]=l;
++l;
}
for(auto i : V[x]) if(odw[i]==0) DFS(i, v+1);
if(v%2==1) {
T[x]=l;
++l;
}
}
vector<int>label(int n, int k, vector<int>u, vector<int>v) {
rep(i, n) {
odw[i]=0;
V[i].clear();
}
rep(i, n-1) {
V[u[i]].pb(v[i]);
V[v[i]].pb(u[i]);
}
l=0;
DFS(0, 0);
vector<int>p(n);
rep(i, n) p[i]=T[i];
return p;
}
int find_next_station(int s, int t, vector<int>c) {
if(s==0) {
for(auto i : c) if(i>=t) return i;
} else if(s>=c[0]) {
if(t>s || c.size()>1 && t<c[1]) return c[0];
for(int i=2; i<c.size(); ++i) if(c[i]>t) return c[i-1];
return c.back();
} else {
if(t<s) return c.back();
for(int i=0; i<c.size()-1; ++i) if(c[i]>=t) return c[i];
return c.back();
}
}
컴파일 시 표준 에러 (stderr) 메시지
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:45:24: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
45 | if(t>s || c.size()>1 && t<c[1]) return c[0];
stations.cpp:46:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
46 | for(int i=2; i<c.size(); ++i) if(c[i]>t) return c[i-1];
| ~^~~~~~~~~
stations.cpp:50:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
50 | for(int i=0; i<c.size()-1; ++i) if(c[i]>=t) return c[i];
| ~^~~~~~~~~~~
stations.cpp:53:1: warning: control reaches end of non-void function [-Wreturn-type]
53 | }
| ^
# | 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... |