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 mx = 1e3;
const int mxl = 1e6;
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
vector<vector<int>> ed(n);
for (int i = 0; i < n-1; ++i) {
ed[u[i]].push_back(v[i]);
ed[v[i]].push_back(u[i]);
}
int rt = 0;
for (int i = 0; i < n; ++i){
if (ed[i].size() > ed[rt].size()) rt = i;
}
int x = 1;
vector<int> label(n);
for (auto to : ed[rt]){
int prev = rt;
int l = x * mx - 1;
int cur = to;
while (ed[cur].size() != 1){
label[cur] = l--;
if (ed[cur][0] == prev) prev = cur, cur = ed[cur][1];
else prev = cur, cur = ed[cur][0];
}
label[cur] = l;
x++;
}
label[rt] = mxl;
return label;
}
int find_next_station(int s, int t, vector<int> c) {
if (s == mxl){
for (auto x : c){
if (x / mx == t / mx) return x;
}
} else if (s / mx == t / mx){
if (s > t){
for (auto x : c){
if (s > x) return x;
}
}
else{
for (auto x : c){
if (s < x) return x;
}
}
} else{
for (auto x : c){
if (s < x) return x;
}
}
return c[0];
}
# | 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... |