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<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define pb push_back
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(), x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int M = 1000;
int timer;
vector<vector<int>> g;
void dfs(int v, int p, vector<int>& labels){
int in = timer;
for(auto u : g[v]){
if(u == p)
continue;
dfs(u, v, labels);
}
int ou = timer++;
labels[v] = (M*in + ou);
}
vector<int> label(int n, int k, vector<int> u, vector<int> v){
g.resize(n);
for(int i = 0; i < n; i++){
g[i].clear();
}
for(int i = 0; i < n-1; i++){
g[u[i]].pb(v[i]);
g[v[i]].pb(u[i]);
}
vector<int> labels(n);
timer = 0;
dfs(0, -1, labels);
return labels;
}
int find_next_station(int s, int t, vector<int> c){
int in_s = s / M, ou_s = s % M;
int in_t = t / M, ou_t = t % M;
int id = -1;
for(auto x : c){
int in_x = x / M, ou_x = x % M;
if(in_x <= in_s && ou_s <= ou_x){
id = x;
continue;
}
if(in_x <= in_t && ou_t <= ou_x){
return x;
}
}
return id;
}
# | 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... |