이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "stations.h"
#include<bits/stdc++.h>
using namespace std;
#define in insert
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
// #define int long long
typedef long long ll;
typedef vector<int> vi;
typedef set<int> si;
typedef multiset<int> msi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
vector<vector<int>> g(n);
for(int i = 0; i < n - 1; i++) {
g[u[i]].pb(v[i]);
g[v[i]].pb(u[i]);
}
vector<int> in(n), out(n);
int t = 0;
auto dfs = [&](auto &self, int to, int fr) -> void {
in[to] = t++;
for(int x : g[to]) {
if(x == fr) continue;
self(self, x, to);
}
out[to] = t - 1;
};
dfs(dfs, 0, -1);
vector<int> ret;
for(int i = 0; i < n; i++) {
ret.pb(in[i] * 1000 + out[i]);
}
return ret;
}
int find_next_station(int s, int t, vector<int> c) {
auto isPar = [&](int x, int y) -> bool {
return (x / 1000 <= y / 1000 && x % 1000 >= y % 1000);
};
int par = -1;
for(int i = 0; i < c.size(); i++) {
if(isPar(c[i], s)) par = i;
}
for(int i = 0; i < c.size(); i++) {
if(i == par) continue;
if(isPar(c[i], t)) return c[i];
}
return c[par];
}
컴파일 시 표준 에러 (stderr) 메시지
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:52:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
52 | for(int i = 0; i < c.size(); i++) {
| ~~^~~~~~~~~~
stations.cpp:55:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
55 | for(int i = 0; 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... |