#include <bits/stdc++.h>
using namespace std;
#include "stations.h"
const int N = 1001;
vector<int> adj[N];
int tin[N];
int tout[N];
vector<int> order;
void dfs(int i, int p, int tp) {
if (!tp) order.push_back(i);
else order.push_back(-1);
for (int c: adj[i]) {
if (c == p) continue;
dfs(c,i, !tp);
}
if (tp) order.push_back(i);
else order.push_back(-1);
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
order.clear(); for (int i=0; i<n; i++) adj[i].clear();
std::vector<int> labels(n);
for (int i=0; i<n-1; i++) {
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
dfs(0,0,0);
for (int i=0; i<2*n; i++) if (order[i]!=-1) labels[order[i]] = i;
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
if (s > c[0]) {
// s is time-out, all neighbors are time-in
// c[0] is the parent
int n = c.size();
vector<int> tout(n);
for (int i=1; i<n-1; i++) {
tout[i] = c[i+1] - 1;
}
tout[n-1] = s - 1;
for (int i=1; i<n; i++) {
if (c[i] <= t && t<=tout[i]) return c[i];
}
return c[0];
} else {
// s is time-in, all neighbors are time-out
// c[n-1] is the parent
int n = c.size();
vector<int> tin(n);
for (int i=n-2; i>0; i--) {
tin[i] = c[i-1] + 1;
}
tin[0] = s + 1;
for (int i=0; i<n-1; i++) {
if (tin[i] <= t && t<=c[i]) return c[i];
}
return c[n-1];
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
596 KB |
Invalid labels (values out of range). scenario=2, k=1000, vertex=1, label=1990 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
344 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1022 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
393 ms |
940 KB |
Output is correct |
2 |
Correct |
308 ms |
932 KB |
Output is correct |
3 |
Correct |
611 ms |
684 KB |
Output is correct |
4 |
Correct |
464 ms |
684 KB |
Output is correct |
5 |
Correct |
374 ms |
684 KB |
Output is correct |
6 |
Correct |
300 ms |
940 KB |
Output is correct |
7 |
Correct |
337 ms |
684 KB |
Output is correct |
8 |
Correct |
1 ms |
768 KB |
Output is correct |
9 |
Correct |
2 ms |
1020 KB |
Output is correct |
10 |
Correct |
0 ms |
768 KB |
Output is correct |
11 |
Correct |
420 ms |
684 KB |
Output is correct |
12 |
Correct |
299 ms |
1048 KB |
Output is correct |
13 |
Correct |
333 ms |
1296 KB |
Output is correct |
14 |
Correct |
332 ms |
684 KB |
Output is correct |
15 |
Correct |
30 ms |
764 KB |
Output is correct |
16 |
Correct |
32 ms |
768 KB |
Output is correct |
17 |
Correct |
66 ms |
744 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
628 ms |
684 KB |
Output is correct |
2 |
Correct |
458 ms |
684 KB |
Output is correct |
3 |
Correct |
396 ms |
684 KB |
Output is correct |
4 |
Correct |
1 ms |
772 KB |
Output is correct |
5 |
Correct |
2 ms |
776 KB |
Output is correct |
6 |
Correct |
0 ms |
768 KB |
Output is correct |
7 |
Correct |
399 ms |
684 KB |
Output is correct |
8 |
Correct |
602 ms |
684 KB |
Output is correct |
9 |
Correct |
417 ms |
684 KB |
Output is correct |
10 |
Correct |
381 ms |
684 KB |
Output is correct |
11 |
Correct |
2 ms |
776 KB |
Output is correct |
12 |
Correct |
2 ms |
768 KB |
Output is correct |
13 |
Correct |
2 ms |
768 KB |
Output is correct |
14 |
Correct |
1 ms |
780 KB |
Output is correct |
15 |
Correct |
0 ms |
768 KB |
Output is correct |
16 |
Correct |
357 ms |
680 KB |
Output is correct |
17 |
Correct |
330 ms |
684 KB |
Output is correct |
18 |
Correct |
331 ms |
684 KB |
Output is correct |
19 |
Correct |
347 ms |
684 KB |
Output is correct |
20 |
Correct |
354 ms |
684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
338 ms |
932 KB |
Partially correct |
2 |
Partially correct |
306 ms |
932 KB |
Partially correct |
3 |
Correct |
629 ms |
684 KB |
Output is correct |
4 |
Correct |
432 ms |
684 KB |
Output is correct |
5 |
Correct |
373 ms |
684 KB |
Output is correct |
6 |
Partially correct |
310 ms |
1192 KB |
Partially correct |
7 |
Partially correct |
324 ms |
684 KB |
Partially correct |
8 |
Correct |
2 ms |
768 KB |
Output is correct |
9 |
Correct |
2 ms |
776 KB |
Output is correct |
10 |
Correct |
0 ms |
768 KB |
Output is correct |
11 |
Partially correct |
327 ms |
684 KB |
Partially correct |
12 |
Partially correct |
378 ms |
684 KB |
Partially correct |
13 |
Correct |
655 ms |
684 KB |
Output is correct |
14 |
Correct |
440 ms |
688 KB |
Output is correct |
15 |
Correct |
411 ms |
684 KB |
Output is correct |
16 |
Partially correct |
317 ms |
684 KB |
Partially correct |
17 |
Correct |
411 ms |
684 KB |
Output is correct |
18 |
Partially correct |
302 ms |
804 KB |
Partially correct |
19 |
Partially correct |
310 ms |
1064 KB |
Partially correct |
20 |
Partially correct |
281 ms |
684 KB |
Partially correct |
21 |
Correct |
29 ms |
768 KB |
Output is correct |
22 |
Partially correct |
35 ms |
764 KB |
Partially correct |
23 |
Partially correct |
51 ms |
716 KB |
Partially correct |
24 |
Correct |
2 ms |
772 KB |
Output is correct |
25 |
Correct |
2 ms |
772 KB |
Output is correct |
26 |
Correct |
2 ms |
768 KB |
Output is correct |
27 |
Correct |
2 ms |
768 KB |
Output is correct |
28 |
Correct |
0 ms |
768 KB |
Output is correct |
29 |
Correct |
345 ms |
684 KB |
Output is correct |
30 |
Correct |
329 ms |
684 KB |
Output is correct |
31 |
Correct |
356 ms |
684 KB |
Output is correct |
32 |
Correct |
355 ms |
932 KB |
Output is correct |
33 |
Correct |
357 ms |
684 KB |
Output is correct |
34 |
Partially correct |
235 ms |
916 KB |
Partially correct |
35 |
Partially correct |
302 ms |
932 KB |
Partially correct |
36 |
Partially correct |
296 ms |
936 KB |
Partially correct |
37 |
Partially correct |
319 ms |
816 KB |
Partially correct |
38 |
Partially correct |
308 ms |
796 KB |
Partially correct |
39 |
Partially correct |
302 ms |
1420 KB |
Partially correct |
40 |
Partially correct |
293 ms |
1032 KB |
Partially correct |
41 |
Partially correct |
336 ms |
1304 KB |
Partially correct |
42 |
Partially correct |
32 ms |
768 KB |
Partially correct |
43 |
Partially correct |
58 ms |
760 KB |
Partially correct |
44 |
Partially correct |
90 ms |
684 KB |
Partially correct |
45 |
Partially correct |
102 ms |
684 KB |
Partially correct |
46 |
Partially correct |
208 ms |
684 KB |
Partially correct |
47 |
Partially correct |
239 ms |
684 KB |
Partially correct |
48 |
Partially correct |
39 ms |
1060 KB |
Partially correct |
49 |
Partially correct |
28 ms |
764 KB |
Partially correct |