#include "stations.h"
#include <bits/stdc++.h>
#define MEM 1111
#define sanic ios_base::sync_with_stdio(0)
#define x first
#define y second
#define sz size()
#define pb push_back
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;
const ll INF = 1e13+7;
const ll MOD = 1e9+7;
vector<ll> g[MEM];
ll lb[MEM];
ll o;
void dfs(ll c, ll lv, ll p){
if(lv&1) lb[c] = o++;
for(ll nt:g[c]){
if(nt==p) continue;
dfs(nt, lv+1, c);
}
if(!(lv&1)) lb[c] = o++;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
std::vector<int> labels(n);
for(int i=0; i<n; i++) g[i].clear();
for(int i=0; i<u.sz; i++){
g[u[i]].pb(v[i]);
g[v[i]].pb(u[i]);
}
memset(lb, 0, sizeof(lb));
o = 0;
dfs(0, 1, -1);
for(int i=0; i<n; i++)
labels[i] = lb[i];
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
if(c.back()<s) reverse(c.begin(), c.end());
for(int r : c)
if(min(s, r)<=t && t<=max(s, r)) return r;
return c.back();
}
Compilation message
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:29:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
29 | for(int i=0; i<u.sz; i++){
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
517 ms |
532 KB |
Output is correct |
2 |
Correct |
423 ms |
544 KB |
Output is correct |
3 |
Correct |
946 ms |
736 KB |
Output is correct |
4 |
Correct |
668 ms |
416 KB |
Output is correct |
5 |
Correct |
590 ms |
544 KB |
Output is correct |
6 |
Correct |
405 ms |
632 KB |
Output is correct |
7 |
Correct |
453 ms |
544 KB |
Output is correct |
8 |
Correct |
2 ms |
620 KB |
Output is correct |
9 |
Correct |
3 ms |
500 KB |
Output is correct |
10 |
Correct |
2 ms |
620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
427 ms |
660 KB |
Output is correct |
2 |
Correct |
501 ms |
688 KB |
Output is correct |
3 |
Correct |
838 ms |
416 KB |
Output is correct |
4 |
Correct |
642 ms |
544 KB |
Output is correct |
5 |
Correct |
551 ms |
532 KB |
Output is correct |
6 |
Correct |
353 ms |
524 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
537 ms |
736 KB |
Output is correct |
2 |
Correct |
544 ms |
736 KB |
Output is correct |
3 |
Correct |
951 ms |
756 KB |
Output is correct |
4 |
Correct |
631 ms |
416 KB |
Output is correct |
5 |
Correct |
529 ms |
740 KB |
Output is correct |
6 |
Correct |
481 ms |
528 KB |
Output is correct |
7 |
Correct |
484 ms |
540 KB |
Output is correct |
8 |
Correct |
2 ms |
848 KB |
Output is correct |
9 |
Correct |
6 ms |
620 KB |
Output is correct |
10 |
Correct |
2 ms |
748 KB |
Output is correct |
11 |
Correct |
639 ms |
476 KB |
Output is correct |
12 |
Correct |
407 ms |
852 KB |
Output is correct |
13 |
Correct |
459 ms |
840 KB |
Output is correct |
14 |
Correct |
433 ms |
532 KB |
Output is correct |
15 |
Correct |
58 ms |
544 KB |
Output is correct |
16 |
Correct |
59 ms |
576 KB |
Output is correct |
17 |
Correct |
133 ms |
796 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
943 ms |
704 KB |
Output is correct |
2 |
Correct |
592 ms |
588 KB |
Output is correct |
3 |
Correct |
577 ms |
536 KB |
Output is correct |
4 |
Correct |
3 ms |
620 KB |
Output is correct |
5 |
Correct |
3 ms |
492 KB |
Output is correct |
6 |
Correct |
1 ms |
620 KB |
Output is correct |
7 |
Correct |
559 ms |
536 KB |
Output is correct |
8 |
Correct |
814 ms |
544 KB |
Output is correct |
9 |
Correct |
556 ms |
528 KB |
Output is correct |
10 |
Correct |
565 ms |
728 KB |
Output is correct |
11 |
Correct |
6 ms |
648 KB |
Output is correct |
12 |
Correct |
5 ms |
760 KB |
Output is correct |
13 |
Correct |
7 ms |
684 KB |
Output is correct |
14 |
Correct |
4 ms |
728 KB |
Output is correct |
15 |
Correct |
2 ms |
628 KB |
Output is correct |
16 |
Correct |
463 ms |
616 KB |
Output is correct |
17 |
Correct |
518 ms |
728 KB |
Output is correct |
18 |
Correct |
451 ms |
776 KB |
Output is correct |
19 |
Correct |
493 ms |
740 KB |
Output is correct |
20 |
Correct |
524 ms |
540 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
560 ms |
912 KB |
Output is correct |
2 |
Correct |
449 ms |
532 KB |
Output is correct |
3 |
Correct |
977 ms |
548 KB |
Output is correct |
4 |
Correct |
675 ms |
540 KB |
Output is correct |
5 |
Correct |
608 ms |
732 KB |
Output is correct |
6 |
Correct |
458 ms |
756 KB |
Output is correct |
7 |
Correct |
439 ms |
544 KB |
Output is correct |
8 |
Correct |
4 ms |
656 KB |
Output is correct |
9 |
Correct |
7 ms |
620 KB |
Output is correct |
10 |
Correct |
1 ms |
812 KB |
Output is correct |
11 |
Correct |
390 ms |
732 KB |
Output is correct |
12 |
Correct |
503 ms |
728 KB |
Output is correct |
13 |
Correct |
843 ms |
612 KB |
Output is correct |
14 |
Correct |
646 ms |
588 KB |
Output is correct |
15 |
Correct |
562 ms |
728 KB |
Output is correct |
16 |
Correct |
435 ms |
536 KB |
Output is correct |
17 |
Correct |
536 ms |
540 KB |
Output is correct |
18 |
Correct |
497 ms |
688 KB |
Output is correct |
19 |
Correct |
554 ms |
788 KB |
Output is correct |
20 |
Correct |
483 ms |
536 KB |
Output is correct |
21 |
Correct |
70 ms |
804 KB |
Output is correct |
22 |
Correct |
76 ms |
544 KB |
Output is correct |
23 |
Correct |
102 ms |
800 KB |
Output is correct |
24 |
Correct |
7 ms |
572 KB |
Output is correct |
25 |
Correct |
6 ms |
808 KB |
Output is correct |
26 |
Correct |
7 ms |
724 KB |
Output is correct |
27 |
Correct |
5 ms |
760 KB |
Output is correct |
28 |
Correct |
2 ms |
620 KB |
Output is correct |
29 |
Correct |
570 ms |
692 KB |
Output is correct |
30 |
Correct |
566 ms |
532 KB |
Output is correct |
31 |
Correct |
577 ms |
664 KB |
Output is correct |
32 |
Correct |
471 ms |
536 KB |
Output is correct |
33 |
Correct |
482 ms |
540 KB |
Output is correct |
34 |
Correct |
365 ms |
740 KB |
Output is correct |
35 |
Correct |
423 ms |
740 KB |
Output is correct |
36 |
Correct |
483 ms |
776 KB |
Output is correct |
37 |
Correct |
492 ms |
812 KB |
Output is correct |
38 |
Correct |
486 ms |
776 KB |
Output is correct |
39 |
Correct |
461 ms |
756 KB |
Output is correct |
40 |
Correct |
418 ms |
784 KB |
Output is correct |
41 |
Correct |
398 ms |
776 KB |
Output is correct |
42 |
Correct |
74 ms |
672 KB |
Output is correct |
43 |
Correct |
103 ms |
720 KB |
Output is correct |
44 |
Correct |
128 ms |
668 KB |
Output is correct |
45 |
Correct |
145 ms |
732 KB |
Output is correct |
46 |
Correct |
287 ms |
724 KB |
Output is correct |
47 |
Correct |
313 ms |
732 KB |
Output is correct |
48 |
Correct |
63 ms |
752 KB |
Output is correct |
49 |
Correct |
72 ms |
860 KB |
Output is correct |