| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 306171 | aljasdlas | Stations (IOI20_stations) | C++14 | 1081 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 <vector>
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> AdjList;
vector<int> labels;
int curLabel;
void dfs(int u, int p, int d) {
if(d%2==0)
labels[u] = curLabel++;
for(auto v: AdjList[u]) {
if(v != p)
dfs(v, u, d+1);
}
if(d%2)
labels[u] = curLabel++;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
// n = 10;
// u.resize(n);
// v.resize(n);
AdjList.assign(n, vector<int>(0));
labels.assign(n,-1);
curLabel = 0;
for(int i = 0; i < n-1; i++) {
AdjList[u[i]].push_back(v[i]);
AdjList[v[i]].push_back(u[i]);
}
dfs(0, -1, 0);
return labels;
}
int find_next_station(int s, int t, vector<int> c) {
sort(c.begin(), c.end());
for(auto x: c)
if(x == t)
return x;
if(c.size() == 0)
return c[0];
if(s < c[0]) {
if(t < s) return c.back();
for(int i = 0; i < c.size()-1; i++)
if(t < c[i])
return c[i];
return c.back();
} else {
if(t > s) return c[0];
for(int i = c.size()-1; i > 0; i--)
if(t > c[i])
return c[i];
return c[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... | ||||
