#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
vector<vector<int>> g(n);
for (int i = 0; i + 1 < n; i++) {
g[u[i]].push_back(v[i]);
g[v[i]].push_back(u[i]);
}
vector<int> tin(n), tout(n), lab(n);
int T = 0;
function<void(int, int, int)> Dfs = [&](int v, int pv, int d) {
if (d % 2 == 0) {
lab[v] = ++T;
}
for (int u : g[v]) {
if (u == pv) {
continue;
}
Dfs(u, v, d ^ 1);
}
if (d % 2 == 1) {
lab[v] = ++T;
}
};
Dfs(0, 0, 0);
return lab;
}
int find_next_station(int s, int t, vector<int> c) {
int n = (int) c.size();
if (n == 1) {
return c[0];
}
if (s <= c[0]) {
if (t >= s && t <= c[0]) {
return c[0];
}
for (int i = 1; i + 1 < n; i++) {
if (t >= c[i - 1] && t <= c[i]) {
return c[i];
}
}
return c[n - 1];
} else {
if (t >= c[n - 1] && t <= s) {
return c[n - 1];
}
for (int i = n - 2; i > 0; i--) {
if (t >= c[i] && t < c[i]) {
return c[i];
}
}
return c[0];
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
455 ms |
624 KB |
Output is correct |
2 |
Correct |
368 ms |
732 KB |
Output is correct |
3 |
Correct |
729 ms |
488 KB |
Output is correct |
4 |
Correct |
576 ms |
416 KB |
Output is correct |
5 |
Correct |
424 ms |
416 KB |
Output is correct |
6 |
Correct |
363 ms |
668 KB |
Output is correct |
7 |
Correct |
333 ms |
544 KB |
Output is correct |
8 |
Correct |
1 ms |
500 KB |
Output is correct |
9 |
Correct |
4 ms |
500 KB |
Output is correct |
10 |
Correct |
2 ms |
492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
366 ms |
592 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
474 ms |
684 KB |
Output is correct |
2 |
Correct |
384 ms |
624 KB |
Output is correct |
3 |
Correct |
636 ms |
500 KB |
Output is correct |
4 |
Correct |
557 ms |
420 KB |
Output is correct |
5 |
Correct |
481 ms |
500 KB |
Output is correct |
6 |
Correct |
382 ms |
628 KB |
Output is correct |
7 |
Correct |
363 ms |
628 KB |
Output is correct |
8 |
Correct |
3 ms |
492 KB |
Output is correct |
9 |
Correct |
3 ms |
496 KB |
Output is correct |
10 |
Correct |
3 ms |
496 KB |
Output is correct |
11 |
Incorrect |
471 ms |
420 KB |
Wrong query response. |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
748 ms |
504 KB |
Output is correct |
2 |
Correct |
558 ms |
496 KB |
Output is correct |
3 |
Correct |
497 ms |
420 KB |
Output is correct |
4 |
Correct |
2 ms |
492 KB |
Output is correct |
5 |
Correct |
4 ms |
492 KB |
Output is correct |
6 |
Correct |
1 ms |
496 KB |
Output is correct |
7 |
Incorrect |
488 ms |
504 KB |
Wrong query response. |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
443 ms |
672 KB |
Output is correct |
2 |
Correct |
356 ms |
796 KB |
Output is correct |
3 |
Correct |
653 ms |
420 KB |
Output is correct |
4 |
Correct |
564 ms |
416 KB |
Output is correct |
5 |
Correct |
459 ms |
416 KB |
Output is correct |
6 |
Correct |
395 ms |
632 KB |
Output is correct |
7 |
Correct |
357 ms |
632 KB |
Output is correct |
8 |
Correct |
3 ms |
492 KB |
Output is correct |
9 |
Correct |
3 ms |
500 KB |
Output is correct |
10 |
Correct |
2 ms |
492 KB |
Output is correct |
11 |
Incorrect |
367 ms |
520 KB |
Wrong query response. |
12 |
Halted |
0 ms |
0 KB |
- |