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;
const int MAXN = 1e3 + 7;
void dfs( vector<vector<int>> adj, int v, int p, vector<int> &lb, int &cnt ) {
lb[v] = cnt++;
for ( auto u: adj[v] ) {
if ( u != p ) {
dfs( adj, u, v, lb, cnt );
}
}
lb[v] *= 1000;
if ( cnt == 1000 ) {
cnt--;
}
lb[v] += cnt;
}
vector<int> label(int n, int k, vector<int> U, vector<int> V) {
vector < vector < int > > adj(n + 1);
for ( int i = 0; i < n - 1; i++ ) {
int u = U[i], v = V[i];
adj[u].push_back(v);
adj[v].push_back(u);
}
vector < int > lb(n);
int cnt = 0;
dfs( adj, 0, -1, lb, cnt );
return lb;
}
int find_next_station(int s, int t, vector<int> c) {
int tins = s / 1000, touts = s % 1000;
int tint = t / 1000, toutt = t % 1000;
int pr = -1;
for ( auto u: c ) {
int tinu = u / 1000, toutu = u % 1000;
if ( tinu <= tins && toutu >= touts ) {
pr = u;
continue;
}
if ( tinu <= tint && toutu >= toutt ) {
return u;
}
}
assert( pr != -1 );
return pr;
}
# | 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... |