# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
431525 | 2021-06-17T12:42:22 Z | idk321 | Stations (IOI20_stations) | C++17 | 1200 ms | 824 KB |
#include "stations.h" #include <vector> using namespace std; #include <bits/stdc++.h> const int M = 1000000000; const int N = 1000; int in[N]; int out[N]; vector<int> adj[N]; vector<int> labels; int n, k; int timer; void dfs2(int node, int par) { timer++; in[node] = timer; for (int next : adj[node]) { if (next == par) continue; dfs2(next, node); } out[node] = timer; } array<int, 2> getInAndOut(int num) { int cur = 0; for (int i = 0; i < 1000; i++) { if (cur + 1000 - i < num) { cur += 1000 - i; continue; } for (int j = i; j < 1000; j++) { if (cur == num) { return {i, j}; } cur++; } } } int getLabel(int nin, int nout) { int cur = 0; for (int i = 0; i < 1000; i++) { if (i < nin) { cur += (1000 - i); continue; } for (int j = i; j < 1000; j++) { if (i == nin && j == nout) { return cur; } cur++; } } return -1; } std::vector<int> label(int n1, int k1, std::vector<int> u, std::vector<int> v) { n = n1; k = k1; labels.assign(n, 0); for (int i = 0; i < n; i++) adj[i].clear(); for (int i = 0; i < u.size(); i++) { adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); } timer = -1; dfs2(0, -1); for (int i = 0; i < n; i++) { labels[i] = getLabel(in[i], out[i]); } return labels; } int find_next_station(int s, int t, std::vector<int> c) { int sIn = getInAndOut(s)[0]; int sOut = getInAndOut(s)[1]; int tIn = getInAndOut(t)[0]; int tOut = getInAndOut(t)[1]; if (sIn <= tIn && tOut <= sOut) { for (int next : c) { int nextIn = getInAndOut(next)[0]; int nextOut = getInAndOut(next)[1]; if (!(nextIn <= sIn && sOut <= nextOut) && (nextIn <= tIn && tOut <= nextOut)) return next; } } else { for (int next : c) { int nextIn = getInAndOut(next)[0]; int nextOut = getInAndOut(next)[1]; if (nextIn <= sIn && sOut <= nextOut) return next; } } return c[0]; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 396 KB | Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=5988 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 10 ms | 500 KB | Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1510 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 696 ms | 492 KB | Output is correct |
2 | Correct | 782 ms | 532 KB | Output is correct |
3 | Correct | 1045 ms | 516 KB | Output is correct |
4 | Correct | 758 ms | 656 KB | Output is correct |
5 | Correct | 731 ms | 400 KB | Output is correct |
6 | Correct | 816 ms | 608 KB | Output is correct |
7 | Correct | 735 ms | 528 KB | Output is correct |
8 | Correct | 6 ms | 468 KB | Output is correct |
9 | Correct | 5 ms | 448 KB | Output is correct |
10 | Correct | 2 ms | 468 KB | Output is correct |
11 | Correct | 766 ms | 400 KB | Output is correct |
12 | Correct | 757 ms | 748 KB | Output is correct |
13 | Correct | 712 ms | 692 KB | Output is correct |
14 | Correct | 633 ms | 536 KB | Output is correct |
15 | Correct | 130 ms | 528 KB | Output is correct |
16 | Correct | 167 ms | 728 KB | Output is correct |
17 | Correct | 267 ms | 788 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1200 ms | 504 KB | Output is correct |
2 | Correct | 826 ms | 488 KB | Output is correct |
3 | Correct | 677 ms | 536 KB | Output is correct |
4 | Correct | 2 ms | 700 KB | Output is correct |
5 | Correct | 4 ms | 468 KB | Output is correct |
6 | Correct | 2 ms | 468 KB | Output is correct |
7 | Correct | 771 ms | 512 KB | Output is correct |
8 | Correct | 1101 ms | 572 KB | Output is correct |
9 | Correct | 864 ms | 636 KB | Output is correct |
10 | Correct | 760 ms | 508 KB | Output is correct |
11 | Correct | 8 ms | 468 KB | Output is correct |
12 | Correct | 9 ms | 480 KB | Output is correct |
13 | Correct | 5 ms | 576 KB | Output is correct |
14 | Correct | 3 ms | 468 KB | Output is correct |
15 | Correct | 2 ms | 616 KB | Output is correct |
16 | Correct | 594 ms | 528 KB | Output is correct |
17 | Correct | 500 ms | 568 KB | Output is correct |
18 | Correct | 598 ms | 512 KB | Output is correct |
19 | Correct | 646 ms | 512 KB | Output is correct |
20 | Correct | 693 ms | 508 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Partially correct | 553 ms | 596 KB | Partially correct |
2 | Partially correct | 824 ms | 508 KB | Partially correct |
3 | Correct | 1091 ms | 500 KB | Output is correct |
4 | Partially correct | 823 ms | 508 KB | Partially correct |
5 | Partially correct | 646 ms | 400 KB | Partially correct |
6 | Partially correct | 785 ms | 504 KB | Partially correct |
7 | Partially correct | 665 ms | 512 KB | Partially correct |
8 | Partially correct | 5 ms | 600 KB | Partially correct |
9 | Partially correct | 5 ms | 596 KB | Partially correct |
10 | Partially correct | 2 ms | 468 KB | Partially correct |
11 | Partially correct | 703 ms | 540 KB | Partially correct |
12 | Partially correct | 684 ms | 560 KB | Partially correct |
13 | Correct | 1045 ms | 400 KB | Output is correct |
14 | Partially correct | 826 ms | 512 KB | Partially correct |
15 | Partially correct | 722 ms | 512 KB | Partially correct |
16 | Partially correct | 646 ms | 500 KB | Partially correct |
17 | Partially correct | 727 ms | 528 KB | Partially correct |
18 | Partially correct | 636 ms | 644 KB | Partially correct |
19 | Partially correct | 709 ms | 704 KB | Partially correct |
20 | Partially correct | 624 ms | 500 KB | Partially correct |
21 | Partially correct | 137 ms | 712 KB | Partially correct |
22 | Partially correct | 163 ms | 572 KB | Partially correct |
23 | Partially correct | 234 ms | 648 KB | Partially correct |
24 | Partially correct | 6 ms | 468 KB | Partially correct |
25 | Partially correct | 6 ms | 448 KB | Partially correct |
26 | Partially correct | 7 ms | 468 KB | Partially correct |
27 | Partially correct | 4 ms | 468 KB | Partially correct |
28 | Partially correct | 4 ms | 468 KB | Partially correct |
29 | Partially correct | 729 ms | 536 KB | Partially correct |
30 | Partially correct | 641 ms | 512 KB | Partially correct |
31 | Partially correct | 607 ms | 524 KB | Partially correct |
32 | Partially correct | 645 ms | 512 KB | Partially correct |
33 | Partially correct | 698 ms | 400 KB | Partially correct |
34 | Partially correct | 577 ms | 512 KB | Partially correct |
35 | Partially correct | 701 ms | 740 KB | Partially correct |
36 | Partially correct | 662 ms | 512 KB | Partially correct |
37 | Partially correct | 653 ms | 708 KB | Partially correct |
38 | Partially correct | 718 ms | 680 KB | Partially correct |
39 | Partially correct | 672 ms | 700 KB | Partially correct |
40 | Partially correct | 754 ms | 776 KB | Partially correct |
41 | Partially correct | 707 ms | 612 KB | Partially correct |
42 | Partially correct | 173 ms | 520 KB | Partially correct |
43 | Partially correct | 233 ms | 656 KB | Partially correct |
44 | Partially correct | 198 ms | 596 KB | Partially correct |
45 | Partially correct | 260 ms | 660 KB | Partially correct |
46 | Partially correct | 501 ms | 512 KB | Partially correct |
47 | Partially correct | 487 ms | 604 KB | Partially correct |
48 | Partially correct | 88 ms | 656 KB | Partially correct |
49 | Partially correct | 131 ms | 824 KB | Partially correct |