이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
typedef pair<ll , ll> ii;
#define ff first
#define ss second
#define pb push_back
#define in insert
const ll N = 1005;
vector < ll > v[N];
vector < int > labels;
ll in[N], out[N];
ll tim = 0;
void dfs(ll s, ll p = -1, ll d = 0){
in[s] = tim; tim++;
for(auto u : v[s]){
if(u - p){
dfs(u, s, d + 1);
}
}
out[s] = tim; tim++;
if(d&1) labels[s] = in[s];
else labels[s] = out[s];
}
std::vector<int> label(int n, int k, std::vector<int> U, std::vector<int> V) {
for(ll i = 0; i < n; i++) v[i].clear();
labels.clear(); tim = 0;
for(ll i = 0; i < n - 1; i++){
ll x = U[i], y = V[i];
v[x].pb(y);
v[y].pb(x);
}
labels.resize(n);
dfs(0);
//for(auto u : labels) cout << u << ' ';
//cout << '\n';
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
if(c.size() == 1){
return c[0];
}
//s = (s * 2) + 1;
//t = (t * 2) + 1;
for(ll i = 0; i < c.size(); i++){
// c[i] = (c[i] * 2) + 1;
}
if(s == 1){
c.pb(1e9);
for(ll i = 1; i < c.size(); i++){
if(t < c[i]) return c[i - 1];
}
}
bool f = 1;
for(auto u : c){
if(u <= s) f = 0;
}
if(f){
// s is IN
ll par = c.back(); c.pop_back();
c.emplace(c.begin(), s);
for(ll i = 1; i < c.size(); i++){
if(c[i - 1] < t && t <= c[i]) return c[i];
}
return par;
}
// s is OUT
ll par = c[0];
c.pb(s);
for(ll i = 2; i < c.size(); i++){
if(c[i - 1] <= t && t < c[i]) return c[i - 1];
}
return par;
}
컴파일 시 표준 에러 (stderr) 메시지
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:60:18: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
60 | for(ll i = 0; i < c.size(); i++){
| ~~^~~~~~~~~~
stations.cpp:65:19: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
65 | for(ll i = 1; i < c.size(); i++){
| ~~^~~~~~~~~~
stations.cpp:77:19: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
77 | for(ll i = 1; i < c.size(); i++){
| ~~^~~~~~~~~~
stations.cpp:85:18: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
85 | for(ll i = 2; i < c.size(); 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... |