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>
#include "stations.h"
using namespace std;
typedef long long ll;
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
vector<ll> degree(n);
vector<vector<int>> adj(n);
for (ll i = 0; i < n-1; i++) {
degree[u[i]]++;
degree[v[i]]++;
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
ll one = 0;
for (ll i = 0; i < n; i++) {
if (degree[i] == 1) {
one = i;
break;
}
}
vector<int> res(n);
ll prev = -1;
for (ll i = 0; i < n; i++) {
res[one] = i;
for (auto &e : adj[one]) {
if (e != prev) {
prev = one;
one = e;
break;
}
}
}
return res;
}
int find_next_station(int s, int t, vector<int> c) {
if (t > s) return s + 1;
else return s - 1;
}
# | 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... |