This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 in(n), out(n);
auto dfs = [&](auto &dfs, int now, int p) -> void {
in[now] = idx++;
for (int nx : G[now]) {
if (nx == p) continue;
dfs(dfs, nx, now);
}
out[now] = idx - 1;
};
dfs(dfs, 0, -1);
vi res(n);
rep(i, n) {
res[i] = in[i] * 1000 + out[i];
}
return res;
}
bool in(int i, int j) {
j /= 1000;
return i / 1000 <= j and j <= i % 1000;
}
int find_next_station(int s, int t, vi c) {
int p = -1;
for (int i : c) {
if (i < s) {
p = i;
continue;
}
if (in(i, t)) return i;
}
assert(p != -1);
return p;
}
# | 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... |