# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
335840 | aanastasov | Stations (IOI20_stations) | C++17 | 988 ms | 1208 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 <algorithm>
#include <cassert>
//#include <iostream>
#include <vector>
void dfs(int src, int parent, int depth, std::vector<std::vector<int>>& adj,
int& nextLabel, std::vector<int>& labels) {
if (depth % 2 == 0) {
labels[src] = nextLabel++;
}
for (int dst : adj[src]) {
if (dst == parent) continue;
dfs(dst, src, depth + 1, adj, nextLabel, labels);
}
if (depth % 2 == 1) {
labels[src] = nextLabel++;
}
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
assert(n <= k);
auto adj = std::vector<std::vector<int>>(n, std::vector<int>());
assert(u.size() == v.size());
for (int index = 0; index < u.size(); ++index) {
adj[u[index]].push_back(v[index]);
adj[v[index]].push_back(u[index]);
}
auto labels = std::vector<int>(n, -1);
int nextLabel = 0;
Compilation message (stderr)
# | 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... |