# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
431961 |
2021-06-17T17:44:08 Z |
Ozy |
Stations (IOI20_stations) |
C++17 |
|
920 ms |
784 KB |
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define repa(i,a,b) for(int i = (a); i >= (b); i--)
#define debug(a) cout << #a << " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "
#define MAX 1000
lli act,ini,fin;
vector<lli> hijos[MAX+2];
vector<int> res;
void DFS (lli pos, lli padre, lli prof) {
if ((prof%2) == 0) res[pos] = act++;
for (auto h : hijos[pos]) {
if (h == padre) continue;
DFS(h,pos,prof+1);
}
if ((prof%2) == 1) res[pos] = act++;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
rep(i,0,n-1) hijos[i].clear();
vector<int>().swap(res);
res.resize(n);
rep(i,0,n-2) {
hijos[u[i]].push_back(v[i]);
hijos[v[i]].push_back(u[i]);
}
act = 0;
DFS(0,0,0);
return res;
}
int find_next_station(int s, int t, std::vector<int> c) {
if (c.size() == 1) return c[0];
if (s == 0) rep (i,0,c.size()-1) if (t <= c[i]) return c[i];
if (s < c[0]) {
ini = s;
fin = c[c.size()-2];
if (t < ini || t > fin) return c[c.size()-1];
rep (i,0,c.size()-2) if (t <= c[i]) return c[i];
}
else {
ini = c[1];
fin = s;
if (t < ini || t > fin) return c[0];
repa (i,c.size()-1,1) if (t >= c[i]) return c[i];
}
return c[0];
}
Compilation message
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:5:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
5 | #define rep(i,a,b) for(int i = (a); i <= (b); i++)
| ^
stations.cpp:47:17: note: in expansion of macro 'rep'
47 | if (s == 0) rep (i,0,c.size()-1) if (t <= c[i]) return c[i];
| ^~~
stations.cpp:5:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
5 | #define rep(i,a,b) for(int i = (a); i <= (b); i++)
| ^
stations.cpp:55:9: note: in expansion of macro 'rep'
55 | rep (i,0,c.size()-2) if (t <= c[i]) return c[i];
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
531 ms |
528 KB |
Output is correct |
2 |
Correct |
409 ms |
512 KB |
Output is correct |
3 |
Correct |
843 ms |
488 KB |
Output is correct |
4 |
Correct |
635 ms |
516 KB |
Output is correct |
5 |
Correct |
579 ms |
528 KB |
Output is correct |
6 |
Correct |
465 ms |
528 KB |
Output is correct |
7 |
Correct |
438 ms |
528 KB |
Output is correct |
8 |
Correct |
3 ms |
468 KB |
Output is correct |
9 |
Correct |
5 ms |
468 KB |
Output is correct |
10 |
Correct |
2 ms |
476 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
417 ms |
620 KB |
Output is correct |
2 |
Correct |
523 ms |
512 KB |
Output is correct |
3 |
Correct |
920 ms |
400 KB |
Output is correct |
4 |
Correct |
630 ms |
508 KB |
Output is correct |
5 |
Correct |
550 ms |
512 KB |
Output is correct |
6 |
Correct |
436 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
552 ms |
508 KB |
Output is correct |
2 |
Correct |
450 ms |
512 KB |
Output is correct |
3 |
Correct |
877 ms |
412 KB |
Output is correct |
4 |
Correct |
651 ms |
400 KB |
Output is correct |
5 |
Correct |
587 ms |
400 KB |
Output is correct |
6 |
Correct |
471 ms |
516 KB |
Output is correct |
7 |
Correct |
460 ms |
516 KB |
Output is correct |
8 |
Correct |
3 ms |
468 KB |
Output is correct |
9 |
Correct |
4 ms |
480 KB |
Output is correct |
10 |
Correct |
2 ms |
468 KB |
Output is correct |
11 |
Correct |
569 ms |
400 KB |
Output is correct |
12 |
Correct |
437 ms |
632 KB |
Output is correct |
13 |
Correct |
481 ms |
736 KB |
Output is correct |
14 |
Correct |
466 ms |
528 KB |
Output is correct |
15 |
Correct |
58 ms |
400 KB |
Output is correct |
16 |
Correct |
66 ms |
528 KB |
Output is correct |
17 |
Correct |
102 ms |
528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
866 ms |
528 KB |
Output is correct |
2 |
Correct |
619 ms |
400 KB |
Output is correct |
3 |
Correct |
555 ms |
400 KB |
Output is correct |
4 |
Correct |
3 ms |
468 KB |
Output is correct |
5 |
Correct |
3 ms |
476 KB |
Output is correct |
6 |
Correct |
2 ms |
468 KB |
Output is correct |
7 |
Correct |
616 ms |
512 KB |
Output is correct |
8 |
Correct |
884 ms |
400 KB |
Output is correct |
9 |
Correct |
667 ms |
512 KB |
Output is correct |
10 |
Correct |
606 ms |
412 KB |
Output is correct |
11 |
Correct |
6 ms |
468 KB |
Output is correct |
12 |
Correct |
6 ms |
480 KB |
Output is correct |
13 |
Correct |
5 ms |
476 KB |
Output is correct |
14 |
Correct |
4 ms |
468 KB |
Output is correct |
15 |
Correct |
2 ms |
468 KB |
Output is correct |
16 |
Correct |
447 ms |
528 KB |
Output is correct |
17 |
Correct |
524 ms |
540 KB |
Output is correct |
18 |
Correct |
534 ms |
656 KB |
Output is correct |
19 |
Correct |
487 ms |
400 KB |
Output is correct |
20 |
Correct |
510 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
538 ms |
644 KB |
Output is correct |
2 |
Correct |
469 ms |
528 KB |
Output is correct |
3 |
Correct |
868 ms |
504 KB |
Output is correct |
4 |
Correct |
678 ms |
508 KB |
Output is correct |
5 |
Correct |
601 ms |
400 KB |
Output is correct |
6 |
Correct |
462 ms |
500 KB |
Output is correct |
7 |
Correct |
471 ms |
508 KB |
Output is correct |
8 |
Correct |
2 ms |
468 KB |
Output is correct |
9 |
Correct |
5 ms |
468 KB |
Output is correct |
10 |
Correct |
2 ms |
524 KB |
Output is correct |
11 |
Correct |
421 ms |
528 KB |
Output is correct |
12 |
Correct |
476 ms |
508 KB |
Output is correct |
13 |
Correct |
860 ms |
400 KB |
Output is correct |
14 |
Correct |
622 ms |
400 KB |
Output is correct |
15 |
Correct |
540 ms |
512 KB |
Output is correct |
16 |
Correct |
491 ms |
512 KB |
Output is correct |
17 |
Correct |
619 ms |
508 KB |
Output is correct |
18 |
Correct |
424 ms |
608 KB |
Output is correct |
19 |
Correct |
476 ms |
740 KB |
Output is correct |
20 |
Correct |
428 ms |
512 KB |
Output is correct |
21 |
Correct |
54 ms |
528 KB |
Output is correct |
22 |
Correct |
99 ms |
528 KB |
Output is correct |
23 |
Correct |
115 ms |
528 KB |
Output is correct |
24 |
Correct |
7 ms |
476 KB |
Output is correct |
25 |
Correct |
6 ms |
468 KB |
Output is correct |
26 |
Correct |
7 ms |
468 KB |
Output is correct |
27 |
Correct |
3 ms |
476 KB |
Output is correct |
28 |
Correct |
2 ms |
468 KB |
Output is correct |
29 |
Correct |
516 ms |
508 KB |
Output is correct |
30 |
Correct |
481 ms |
508 KB |
Output is correct |
31 |
Correct |
544 ms |
512 KB |
Output is correct |
32 |
Correct |
443 ms |
400 KB |
Output is correct |
33 |
Correct |
500 ms |
400 KB |
Output is correct |
34 |
Correct |
314 ms |
492 KB |
Output is correct |
35 |
Correct |
390 ms |
624 KB |
Output is correct |
36 |
Correct |
431 ms |
744 KB |
Output is correct |
37 |
Correct |
455 ms |
740 KB |
Output is correct |
38 |
Correct |
441 ms |
520 KB |
Output is correct |
39 |
Correct |
431 ms |
660 KB |
Output is correct |
40 |
Correct |
473 ms |
648 KB |
Output is correct |
41 |
Correct |
469 ms |
632 KB |
Output is correct |
42 |
Correct |
60 ms |
528 KB |
Output is correct |
43 |
Correct |
122 ms |
604 KB |
Output is correct |
44 |
Correct |
146 ms |
508 KB |
Output is correct |
45 |
Correct |
159 ms |
644 KB |
Output is correct |
46 |
Correct |
255 ms |
500 KB |
Output is correct |
47 |
Correct |
306 ms |
528 KB |
Output is correct |
48 |
Correct |
61 ms |
768 KB |
Output is correct |
49 |
Correct |
61 ms |
784 KB |
Output is correct |