이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "stations.h"
#include "bits/stdc++.h"
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, s, n) for(ll i = ll(s); i < ll(n); i++)
#define rrep(i, n) for(ll i = ll(n)-1; i >= 0; i--)
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<P>;
using vvp = vector<vp>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;
template<class T>
bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T>
bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
vi label(int n, int k, vi u, vi v) {
vvi G(n);
rep(i, n - 1) {
G[u[i]].pb(v[i]);
G[v[i]].pb(u[i]);
}
int idx = 0;
vi res(n);
auto dfs = [&](auto &dfs, int now, int p, int d) -> void {
if (d == 0) res[now] = idx++;
for (int nx : G[now]) {
if (nx == p) continue;
dfs(dfs, nx, now, d ^ 1);
}
if (d == 1) res[now] = idx++;
};
dfs(dfs, 0, -1, 0);
assert(idx == n);
return res;
}
int find_next_station(int s, int t, vi c) {
if (c[0] < s) {
int pre = s;
rrep(i, c.size()) {
if (c[i] <= t and t < pre) return c[i];
pre = c[i];
}
return pre;
} else {
int pre = s;
rep(i, c.size()) {
if (pre < t and t <= c[i]) return c[i];
pre = c[i];
}
return pre;
}
}
# | 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... |