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>
using namespace std;
// macros
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> lll;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<lll> vlll;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define RE(a,c) REP(a,0,c)
#define RE1(a,c) REP(a,1,c+1)
#define REI(a,b,c) REP(a,b,c+1)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define FOR(a,b) for(auto& a : b)
#define all(a) a.begin(), a.end()
#define INF 1e9
#define EPS 1e-9
#define pb push_back
#define popb pop_back
#define fi first
#define se second
#define sz size()
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
vi label(int n, int k, vi u, vi v) {
vector<vi> adj(n,vi(0));
RE(i,n-1) adj[u[i]].pb(v[i]), adj[v[i]].pb(u[i]);
vi labels(n);
int nextLabel = 0;
function<void(int,int,int)> dfs = [&](int u, int p, int cur) {
if(cur) labels[u] = nextLabel++;
FOR(v,adj[u]) {
if(v == p) continue;
dfs(v,u,!cur);
}
if(!cur) labels[u] = nextLabel++;
};
dfs(0,0,0);
return labels;
}
int find_next_station(int s, int t, vi c) {
if(c[0] > s) {
if(t < s || t >= c.back())
return c.back();
auto it = lower_bound(all(c),t);
return *it;
} else {
if(t <= c[0] || t > s)
return c[0];
auto it = upper_bound(all(c),t);
--it;
return *it;
}
}
# | 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... |