# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
305445 | lohacho | Stations (IOI20_stations) | C++14 | 1178 ms | 1280 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>
using namespace std;
using LL = long long;
const int INF = (int)1e9 + 7;
const int NS = (int)1e3 + 4;
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
vector<int> labels(n);
int label_num = 0, chk[NS];
memset(chk, 0, sizeof(chk));
vector < int > way[NS];
for(int i = 0; i < n - 1; ++i){
way[u[i]].push_back(v[i]);
way[v[i]].push_back(u[i]);
}
function < void(int, int) > dfs = [&](int x, int dep){
chk[x] = 1;
if(dep % 2) labels[x] = label_num++;
for(auto&nxt:way[x]){
if(chk[nxt]) continue;
dfs(nxt, dep + 1);
}
if(dep % 2 == 0) labels[x] = label_num++;
};
dfs(0, 1);
return labels;
}
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... |