# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
555364 | ITO | Stations (IOI20_stations) | C++17 | 775 ms | 768 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;
vector<int> e[1000], lab;
int co;
void df(int no, int pa, bool pr) {
if (pr) lab[no] = co++;
for (int ed : e[no]) {
if (ed != pa) df(ed, no, !pr);
}
if (!pr) lab[no] = co++;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
co = 0;
lab.resize(n);
for (int i = 0; i < n; i++) e[i].clear();
for (int i = 0; i < n - 1; i++) {
e[u[i]].push_back(v[i]);
e[v[i]].push_back(u[i]);
}
df(0, 0, 1);
return lab;
}
int find_next_station(int s, int t, std::vector<int> c) {
if (c[0] < s) {
if (t < c[0] || t > s) return c[0];
for (int i = c.size() - 1; i >= 0; i--) if (c[i] <= t) return c[i];
} else {
if (t > c.back() || t < s) return c.back();
for (int i = 0; i < c.size(); i++) if (c[i] >= t) return c[i];
}
}
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... |