# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
309362 |
2020-10-03T10:04:58 Z |
xt0r3 |
Stations (IOI20_stations) |
C++14 |
|
1023 ms |
1232 KB |
#include<bits/stdc++.h>
using namespace std;
int timer;
vector<bool> f;
vector<int> l, d;
vector<vector<int> > g;
void dfs(int id, bool flag = 1){
d[id] = timer++;
f[id] = flag;
for(int v : g[id]) if(d[v] == -1) dfs(v, !flag);
l[id] = timer++;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v){
f.resize(n);
l.assign(n, -1);
d.assign(n, -1);
g.assign(n, {});
for(int i = 0; i < n - 1; i++){
g[u[i]].push_back(v[i]);
g[v[i]].push_back(u[i]);
}
timer = 0;
dfs(0);
vector<int> ret(n);
for(int i = 0; i < n; i++){
ret[i] = (f[i] ? d[i] / 2 : l[i] / 2);
}
return ret;
}
int find_next_station(int s, int t, vector<int> c){
if(s < c[0]){
//c has leaving times
if(t < s || t > c.back()) return c.back();
return *lower_bound(c.begin(), c.end(), t);
}
else{
//c has discovery times
if(t < c.front() || t > s) return c.front();
return *(upper_bound(c.begin(), c.end(), t) - 1);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
577 ms |
772 KB |
Output is correct |
2 |
Correct |
442 ms |
1024 KB |
Output is correct |
3 |
Correct |
887 ms |
640 KB |
Output is correct |
4 |
Correct |
717 ms |
648 KB |
Output is correct |
5 |
Correct |
660 ms |
644 KB |
Output is correct |
6 |
Correct |
511 ms |
768 KB |
Output is correct |
7 |
Correct |
431 ms |
792 KB |
Output is correct |
8 |
Correct |
3 ms |
644 KB |
Output is correct |
9 |
Correct |
5 ms |
640 KB |
Output is correct |
10 |
Correct |
1 ms |
640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
552 ms |
1008 KB |
Output is correct |
2 |
Correct |
568 ms |
828 KB |
Output is correct |
3 |
Correct |
948 ms |
640 KB |
Output is correct |
4 |
Correct |
828 ms |
904 KB |
Output is correct |
5 |
Correct |
667 ms |
640 KB |
Output is correct |
6 |
Correct |
476 ms |
832 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
592 ms |
1056 KB |
Output is correct |
2 |
Correct |
476 ms |
1008 KB |
Output is correct |
3 |
Correct |
910 ms |
640 KB |
Output is correct |
4 |
Correct |
674 ms |
640 KB |
Output is correct |
5 |
Correct |
662 ms |
640 KB |
Output is correct |
6 |
Correct |
439 ms |
784 KB |
Output is correct |
7 |
Correct |
473 ms |
788 KB |
Output is correct |
8 |
Correct |
3 ms |
640 KB |
Output is correct |
9 |
Correct |
5 ms |
640 KB |
Output is correct |
10 |
Correct |
2 ms |
652 KB |
Output is correct |
11 |
Correct |
617 ms |
768 KB |
Output is correct |
12 |
Correct |
509 ms |
772 KB |
Output is correct |
13 |
Correct |
469 ms |
1172 KB |
Output is correct |
14 |
Correct |
477 ms |
768 KB |
Output is correct |
15 |
Correct |
57 ms |
768 KB |
Output is correct |
16 |
Correct |
68 ms |
840 KB |
Output is correct |
17 |
Correct |
110 ms |
812 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
966 ms |
648 KB |
Output is correct |
2 |
Correct |
727 ms |
644 KB |
Output is correct |
3 |
Correct |
765 ms |
640 KB |
Output is correct |
4 |
Correct |
1 ms |
640 KB |
Output is correct |
5 |
Correct |
5 ms |
640 KB |
Output is correct |
6 |
Correct |
3 ms |
640 KB |
Output is correct |
7 |
Correct |
665 ms |
640 KB |
Output is correct |
8 |
Correct |
1023 ms |
640 KB |
Output is correct |
9 |
Correct |
672 ms |
652 KB |
Output is correct |
10 |
Correct |
633 ms |
660 KB |
Output is correct |
11 |
Correct |
7 ms |
904 KB |
Output is correct |
12 |
Correct |
5 ms |
652 KB |
Output is correct |
13 |
Correct |
4 ms |
892 KB |
Output is correct |
14 |
Correct |
4 ms |
640 KB |
Output is correct |
15 |
Correct |
1 ms |
640 KB |
Output is correct |
16 |
Correct |
504 ms |
640 KB |
Output is correct |
17 |
Correct |
637 ms |
780 KB |
Output is correct |
18 |
Correct |
560 ms |
784 KB |
Output is correct |
19 |
Correct |
613 ms |
792 KB |
Output is correct |
20 |
Correct |
563 ms |
640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
597 ms |
1008 KB |
Output is correct |
2 |
Correct |
458 ms |
1024 KB |
Output is correct |
3 |
Correct |
870 ms |
640 KB |
Output is correct |
4 |
Correct |
794 ms |
640 KB |
Output is correct |
5 |
Correct |
645 ms |
640 KB |
Output is correct |
6 |
Correct |
502 ms |
776 KB |
Output is correct |
7 |
Correct |
460 ms |
768 KB |
Output is correct |
8 |
Correct |
3 ms |
640 KB |
Output is correct |
9 |
Correct |
4 ms |
640 KB |
Output is correct |
10 |
Correct |
2 ms |
644 KB |
Output is correct |
11 |
Correct |
484 ms |
768 KB |
Output is correct |
12 |
Correct |
612 ms |
816 KB |
Output is correct |
13 |
Correct |
854 ms |
644 KB |
Output is correct |
14 |
Correct |
730 ms |
776 KB |
Output is correct |
15 |
Correct |
635 ms |
644 KB |
Output is correct |
16 |
Correct |
519 ms |
892 KB |
Output is correct |
17 |
Correct |
688 ms |
644 KB |
Output is correct |
18 |
Correct |
512 ms |
912 KB |
Output is correct |
19 |
Correct |
572 ms |
1024 KB |
Output is correct |
20 |
Correct |
527 ms |
820 KB |
Output is correct |
21 |
Correct |
56 ms |
888 KB |
Output is correct |
22 |
Correct |
75 ms |
852 KB |
Output is correct |
23 |
Correct |
109 ms |
768 KB |
Output is correct |
24 |
Correct |
6 ms |
648 KB |
Output is correct |
25 |
Correct |
7 ms |
640 KB |
Output is correct |
26 |
Correct |
6 ms |
640 KB |
Output is correct |
27 |
Correct |
5 ms |
640 KB |
Output is correct |
28 |
Correct |
2 ms |
648 KB |
Output is correct |
29 |
Correct |
514 ms |
640 KB |
Output is correct |
30 |
Correct |
515 ms |
640 KB |
Output is correct |
31 |
Correct |
494 ms |
644 KB |
Output is correct |
32 |
Correct |
491 ms |
652 KB |
Output is correct |
33 |
Correct |
516 ms |
652 KB |
Output is correct |
34 |
Correct |
318 ms |
1024 KB |
Output is correct |
35 |
Correct |
434 ms |
1024 KB |
Output is correct |
36 |
Correct |
432 ms |
1232 KB |
Output is correct |
37 |
Correct |
507 ms |
1008 KB |
Output is correct |
38 |
Correct |
475 ms |
1040 KB |
Output is correct |
39 |
Correct |
565 ms |
1016 KB |
Output is correct |
40 |
Correct |
513 ms |
1008 KB |
Output is correct |
41 |
Correct |
601 ms |
776 KB |
Output is correct |
42 |
Correct |
63 ms |
768 KB |
Output is correct |
43 |
Correct |
106 ms |
804 KB |
Output is correct |
44 |
Correct |
129 ms |
800 KB |
Output is correct |
45 |
Correct |
196 ms |
780 KB |
Output is correct |
46 |
Correct |
304 ms |
836 KB |
Output is correct |
47 |
Correct |
296 ms |
792 KB |
Output is correct |
48 |
Correct |
60 ms |
768 KB |
Output is correct |
49 |
Correct |
67 ms |
1152 KB |
Output is correct |