#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> adj;
vector<int> lab, in, out;
int dfst;
void dfs (int u = 0, int p = -1, int d = 0) {
in[u] = dfst++;
for (int v : adj[u]) {
if (v ^ p) {
dfs(v, u, d ^ 1);
}
}
out[u] = dfst++;
lab[u] = d ? in[u] : out[u];
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
adj.assign(n, {});
lab.resize(n);
in.resize(n);
out.resize(n);
dfst = 0;
for (int i = 0; i < n - 1; ++i) {
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
dfs();
vector<int> ii = lab;
sort(lab.begin(), lab.end());
for (int i = 0; i < n; ++i) {
ii[i] = lower_bound(lab.begin(), lab.end(), ii[i]) - lab.begin();
}
return ii;
}
int find_next_station(int s, int t, vector<int> c) {
if (c.size() == 1) {
return c[0];
}
if (s < c[0]) {
if (t < s) {
return c.back();
}
return *lower_bound(c.begin(), c.end(), t);
}
else {
if (t > s) {
return c[0];
}
return *(upper_bound(c.begin(), c.end(), t) - 1);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
526 ms |
596 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
725 ms |
488 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
511 ms |
696 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1087 ms |
420 KB |
Output is correct |
2 |
Correct |
744 ms |
564 KB |
Output is correct |
3 |
Correct |
777 ms |
420 KB |
Output is correct |
4 |
Correct |
4 ms |
468 KB |
Output is correct |
5 |
Incorrect |
4 ms |
468 KB |
Wrong query response. |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
596 ms |
608 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |