# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
304944 | ecnerwala | Stations (IOI20_stations) | C++17 | 1154 ms | 1044 KiB |
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 <vector>
#include <cassert>
#include <cmath>
#include <algorithm>
namespace {
void do_label(const std::vector<std::vector<int>>& adj, std::vector<int>& labels, int& cur_idx, int cur, int prv, bool dir) {
if (!dir) {
labels[cur] = cur_idx++;
}
for (int nxt : adj[cur]) {
if (nxt == prv) continue;
do_label(adj, labels, cur_idx, nxt, cur, !dir);
}
if (dir) {
labels[cur] = cur_idx++;
}
}
}
std::vector<int> label(int N, int K, std::vector<int> U, std::vector<int> V) {
std::vector<std::vector<int>> adj(N);
for (int e = 0; e < N-1; e++) {
adj[U[e]].push_back(V[e]);
adj[V[e]].push_back(U[e]);
}
std::vector<int> labels(N);
# | 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... |