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;
vector<vector<int>> adj;
vector<int> label(int N, int K, vector<int> u, vector<int> v) {
adj.resize(N);
for(auto& I : adj) I.clear();
for(int i = 0; i < (int)u.size(); ++i) {
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
vector<int> flat(N);
int root = -1;
for(int i = 0; i < N; ++i) {
if((int)adj[i].size() == 1) { root = i; break; }
}
vector<int> labels(N);
int cur = root, prev = -1;
for(int i = 0; ; ++i) {
flat[i] = cur;
labels[cur] = i;
if(i == N - 1) break;
bool f = (adj[cur][0] == prev);
prev = cur;
cur = adj[i][f];
}
return labels;
}
int find_next_station(int s, int t, vector<int> c) {
if(s > t) {
return s - 1;
}
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... |