#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
void dfs(int u, int p, bool d, const vector <vector <int>> &adj, vector <int> &label) {
static int cnt = 0;
if (!d) label[u] = cnt++;
for (int v : adj[u])
if (v != p) dfs(v, u, !d, adj, label);
if (d) label[u] = cnt++;
}
vector <int> label(int n, int k, vector <int> u, vector <int> v) {
vector <vector <int>> adj(n);
vector <int> label(n);
for (int i = 0; i + 1 < n; i++) {
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
dfs(0, -1, 0, adj, label);
return label;
}
int find_next_station(int s, int t, vector <int> c) {
if (s < c[0]) {
int lo = s, hi = c.size() > 1 ? c[c.size() - 2] : s;
if (lo <= t && t <= hi) {
for (int u : c)
if (u >= t) return u;
}
return c[c.size() - 1];
} else {
int hi = s, lo = c.size() > 1 ? c[1] : s;
if (lo <= t && t <= hi) {
for (int u : c)
if (u <= t) return u;
}
return c[0];
}
return c[0];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
480 KB |
Invalid labels (values out of range). scenario=2, k=1000, vertex=1, label=1008 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
292 KB |
Invalid labels (values out of range). scenario=1, k=1000, vertex=1, label=1507 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
647 ms |
624 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
956 ms |
480 KB |
Output is correct |
2 |
Incorrect |
913 ms |
496 KB |
Wrong query response. |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
650 ms |
656 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |