# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
555364 |
2022-04-30T15:56:47 Z |
ITO |
Stations (IOI20_stations) |
C++17 |
|
775 ms |
768 KB |
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> e[1000], lab;
int co;
void df(int no, int pa, bool pr) {
if (pr) lab[no] = co++;
for (int ed : e[no]) {
if (ed != pa) df(ed, no, !pr);
}
if (!pr) lab[no] = co++;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
co = 0;
lab.resize(n);
for (int i = 0; i < n; i++) e[i].clear();
for (int i = 0; i < n - 1; i++) {
e[u[i]].push_back(v[i]);
e[v[i]].push_back(u[i]);
}
df(0, 0, 1);
return lab;
}
int find_next_station(int s, int t, std::vector<int> c) {
if (c[0] < s) {
if (t < c[0] || t > s) return c[0];
for (int i = c.size() - 1; i >= 0; i--) if (c[i] <= t) return c[i];
} else {
if (t > c.back() || t < s) return c.back();
for (int i = 0; i < c.size(); i++) if (c[i] >= t) return c[i];
}
}
Compilation message
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:31:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
31 | for (int i = 0; i < c.size(); i++) if (c[i] >= t) return c[i];
| ~~^~~~~~~~~~
stations.cpp:33:1: warning: control reaches end of non-void function [-Wreturn-type]
33 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
490 ms |
636 KB |
Output is correct |
2 |
Correct |
384 ms |
656 KB |
Output is correct |
3 |
Correct |
775 ms |
420 KB |
Output is correct |
4 |
Correct |
585 ms |
416 KB |
Output is correct |
5 |
Correct |
515 ms |
416 KB |
Output is correct |
6 |
Correct |
370 ms |
564 KB |
Output is correct |
7 |
Correct |
374 ms |
528 KB |
Output is correct |
8 |
Correct |
1 ms |
492 KB |
Output is correct |
9 |
Correct |
4 ms |
504 KB |
Output is correct |
10 |
Correct |
0 ms |
500 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
373 ms |
532 KB |
Output is correct |
2 |
Correct |
463 ms |
548 KB |
Output is correct |
3 |
Correct |
727 ms |
416 KB |
Output is correct |
4 |
Correct |
543 ms |
416 KB |
Output is correct |
5 |
Correct |
477 ms |
420 KB |
Output is correct |
6 |
Correct |
379 ms |
548 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
476 ms |
644 KB |
Output is correct |
2 |
Correct |
367 ms |
648 KB |
Output is correct |
3 |
Correct |
759 ms |
416 KB |
Output is correct |
4 |
Correct |
571 ms |
564 KB |
Output is correct |
5 |
Correct |
505 ms |
548 KB |
Output is correct |
6 |
Correct |
365 ms |
660 KB |
Output is correct |
7 |
Correct |
417 ms |
536 KB |
Output is correct |
8 |
Correct |
1 ms |
500 KB |
Output is correct |
9 |
Correct |
4 ms |
492 KB |
Output is correct |
10 |
Correct |
1 ms |
492 KB |
Output is correct |
11 |
Correct |
517 ms |
528 KB |
Output is correct |
12 |
Correct |
341 ms |
668 KB |
Output is correct |
13 |
Correct |
357 ms |
704 KB |
Output is correct |
14 |
Correct |
356 ms |
528 KB |
Output is correct |
15 |
Correct |
46 ms |
620 KB |
Output is correct |
16 |
Correct |
59 ms |
600 KB |
Output is correct |
17 |
Correct |
92 ms |
600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
733 ms |
420 KB |
Output is correct |
2 |
Correct |
547 ms |
544 KB |
Output is correct |
3 |
Correct |
457 ms |
420 KB |
Output is correct |
4 |
Correct |
2 ms |
492 KB |
Output is correct |
5 |
Correct |
3 ms |
492 KB |
Output is correct |
6 |
Correct |
1 ms |
500 KB |
Output is correct |
7 |
Correct |
507 ms |
532 KB |
Output is correct |
8 |
Correct |
739 ms |
416 KB |
Output is correct |
9 |
Correct |
513 ms |
532 KB |
Output is correct |
10 |
Correct |
479 ms |
420 KB |
Output is correct |
11 |
Correct |
5 ms |
492 KB |
Output is correct |
12 |
Correct |
5 ms |
492 KB |
Output is correct |
13 |
Correct |
4 ms |
492 KB |
Output is correct |
14 |
Correct |
4 ms |
500 KB |
Output is correct |
15 |
Correct |
1 ms |
500 KB |
Output is correct |
16 |
Correct |
400 ms |
548 KB |
Output is correct |
17 |
Correct |
359 ms |
420 KB |
Output is correct |
18 |
Correct |
465 ms |
416 KB |
Output is correct |
19 |
Correct |
463 ms |
420 KB |
Output is correct |
20 |
Correct |
434 ms |
548 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
447 ms |
672 KB |
Output is correct |
2 |
Correct |
351 ms |
656 KB |
Output is correct |
3 |
Correct |
714 ms |
420 KB |
Output is correct |
4 |
Correct |
622 ms |
420 KB |
Output is correct |
5 |
Correct |
557 ms |
416 KB |
Output is correct |
6 |
Correct |
385 ms |
544 KB |
Output is correct |
7 |
Correct |
401 ms |
536 KB |
Output is correct |
8 |
Correct |
2 ms |
496 KB |
Output is correct |
9 |
Correct |
3 ms |
492 KB |
Output is correct |
10 |
Correct |
1 ms |
492 KB |
Output is correct |
11 |
Correct |
375 ms |
556 KB |
Output is correct |
12 |
Correct |
396 ms |
544 KB |
Output is correct |
13 |
Correct |
686 ms |
416 KB |
Output is correct |
14 |
Correct |
547 ms |
420 KB |
Output is correct |
15 |
Correct |
510 ms |
416 KB |
Output is correct |
16 |
Correct |
331 ms |
548 KB |
Output is correct |
17 |
Correct |
522 ms |
548 KB |
Output is correct |
18 |
Correct |
415 ms |
544 KB |
Output is correct |
19 |
Correct |
435 ms |
660 KB |
Output is correct |
20 |
Correct |
408 ms |
516 KB |
Output is correct |
21 |
Correct |
49 ms |
416 KB |
Output is correct |
22 |
Correct |
57 ms |
600 KB |
Output is correct |
23 |
Correct |
92 ms |
544 KB |
Output is correct |
24 |
Correct |
4 ms |
492 KB |
Output is correct |
25 |
Correct |
5 ms |
488 KB |
Output is correct |
26 |
Correct |
4 ms |
492 KB |
Output is correct |
27 |
Correct |
3 ms |
500 KB |
Output is correct |
28 |
Correct |
1 ms |
500 KB |
Output is correct |
29 |
Correct |
387 ms |
416 KB |
Output is correct |
30 |
Correct |
450 ms |
420 KB |
Output is correct |
31 |
Correct |
427 ms |
548 KB |
Output is correct |
32 |
Correct |
437 ms |
544 KB |
Output is correct |
33 |
Correct |
426 ms |
416 KB |
Output is correct |
34 |
Correct |
288 ms |
544 KB |
Output is correct |
35 |
Correct |
369 ms |
652 KB |
Output is correct |
36 |
Correct |
377 ms |
648 KB |
Output is correct |
37 |
Correct |
388 ms |
628 KB |
Output is correct |
38 |
Correct |
387 ms |
648 KB |
Output is correct |
39 |
Correct |
408 ms |
528 KB |
Output is correct |
40 |
Correct |
346 ms |
664 KB |
Output is correct |
41 |
Correct |
402 ms |
700 KB |
Output is correct |
42 |
Correct |
54 ms |
544 KB |
Output is correct |
43 |
Correct |
93 ms |
660 KB |
Output is correct |
44 |
Correct |
115 ms |
672 KB |
Output is correct |
45 |
Correct |
128 ms |
556 KB |
Output is correct |
46 |
Correct |
246 ms |
560 KB |
Output is correct |
47 |
Correct |
263 ms |
544 KB |
Output is correct |
48 |
Correct |
56 ms |
672 KB |
Output is correct |
49 |
Correct |
52 ms |
768 KB |
Output is correct |