# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
592297 | Soumya1 | Stations (IOI20_stations) | C++17 | 929 ms | 780 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;
const int mxN = 1005;
vector<int> ad[mxN];
int val[mxN];
int timer;
void dfs(int u, int p, int d = 0) {
if (d) val[u] = timer++;
for (int v : ad[u]) {
if (v == p) continue;
dfs(v, u, d ^ 1);
}
if (!d) val[u] = timer++;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
timer = 0;
for (int i = 0; i < n; i++) {
ad[i].clear();
}
for (int i = 0; i < n - 1; i++) {
ad[u[i]].push_back(v[i]);
ad[v[i]].push_back(u[i]);
}
dfs(0, -1);
vector<int> ret(n);
for (int i = 0; i < n; i++) {
ret[i] = val[i];
}
return ret;
}
int find_next_station(int s, int t, vector<int> c) {
if (s > c.back()) {
if (t > s) return c[0];
for (int i = c.size() - 1; i >= 1; i--) {
if (t >= c[i]) return c[i];
}
return c[0];
} else {
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();
}
}
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... |