# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
314825 | kostia244 | Stations (IOI20_stations) | C++17 | 1063 ms | 1160 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 <bits/stdc++.h>
#define all(x) begin(x), end(x)
using namespace std;
namespace lab {
vector<vector<int>> g;
vector<int> tin, tout, d;
int timer;
void dfs(int v, int p) {
timer += d[v]%2 == 0;
tin[v] = timer;
for(auto &i : g[v]) if(i != p) {
d[i] = d[v]+1;
dfs(i, v);
}
timer += d[v]%2 == 1;
tout[v] = timer;
}
};
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
using namespace lab;
timer = -1;
tin = tout = d = vector<int>(n);
g.assign(n, vector<int>());
for(int i = 0; i+1 < n; i++) {
g[u[i]].push_back(v[i]);
g[v[i]].push_back(u[i]);
}
dfs(0, 0);
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... |