#include "stations.h"
#include <algorithm>
#include <iostream>
#include <cassert>
#include <numeric>
#include <vector>
typedef long long llong;
const int MAXN = 1000 + 10;
int n;
int timer;
int in[MAXN];
int out[MAXN];
bool which[MAXN];
std::vector <int> g[MAXN];
void dfs(int node, int p)
{
in[node] = timer++;
for (const int &i : g[node])
{
if (i == p) continue;
which[i] = 1 ^ which[node];
dfs(i, node);
}
out[node] = timer++;
}
std::vector <int> label(int _n, int k, std::vector <int> u, std::vector <int> v)
{
n = _n;
std::fill(which, which + n, 0);
for (int i = 0 ; i < n ; ++i)
{
g[i].clear();
}
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, -1);
std::vector <int> labels(n);
std::vector <std::pair <int,int>> compr;
for (int i = 0 ; i < n ; ++i)
{
labels[i] = (which[i] ? in[i] : out[i]);
compr.push_back({labels[i], i});
}
std::sort(compr.begin(), compr.end());
for (int i = 0 ; i < n ; ++i)
{
labels[compr[i].second] = i;
}
return labels;
}
int find_next_station(int s, int t, std::vector <int> c)
{
std::sort(c.begin(), c.end());
if (s < c[0]) // in time
{
if (t < s)
{
return c.back();
}
for (int i = 0 ; i < (int)(c.size() - 1) ; ++i)
{
if (c[i] >= t)
{
return c[i];
}
}
return c.back();
} else
{
if (t > s)
{
return c[0];
}
for (int i = (int)c.size() - 1 ; i > 0 ; --i)
{
if (c[i] <= t)
{
return c[i];
}
}
return c[0];
}
std::cout << "WTF\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
550 ms |
672 KB |
Output is correct |
2 |
Correct |
480 ms |
676 KB |
Output is correct |
3 |
Correct |
855 ms |
512 KB |
Output is correct |
4 |
Correct |
627 ms |
508 KB |
Output is correct |
5 |
Correct |
558 ms |
544 KB |
Output is correct |
6 |
Correct |
452 ms |
544 KB |
Output is correct |
7 |
Correct |
420 ms |
548 KB |
Output is correct |
8 |
Correct |
2 ms |
620 KB |
Output is correct |
9 |
Correct |
5 ms |
492 KB |
Output is correct |
10 |
Correct |
0 ms |
620 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
454 ms |
548 KB |
Output is correct |
2 |
Correct |
536 ms |
524 KB |
Output is correct |
3 |
Correct |
773 ms |
420 KB |
Output is correct |
4 |
Correct |
565 ms |
520 KB |
Output is correct |
5 |
Correct |
588 ms |
416 KB |
Output is correct |
6 |
Correct |
446 ms |
528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
548 ms |
544 KB |
Output is correct |
2 |
Correct |
412 ms |
648 KB |
Output is correct |
3 |
Correct |
813 ms |
528 KB |
Output is correct |
4 |
Correct |
567 ms |
532 KB |
Output is correct |
5 |
Correct |
614 ms |
532 KB |
Output is correct |
6 |
Correct |
490 ms |
548 KB |
Output is correct |
7 |
Correct |
428 ms |
548 KB |
Output is correct |
8 |
Correct |
2 ms |
632 KB |
Output is correct |
9 |
Correct |
4 ms |
492 KB |
Output is correct |
10 |
Correct |
1 ms |
492 KB |
Output is correct |
11 |
Correct |
455 ms |
420 KB |
Output is correct |
12 |
Correct |
375 ms |
796 KB |
Output is correct |
13 |
Correct |
437 ms |
764 KB |
Output is correct |
14 |
Correct |
397 ms |
544 KB |
Output is correct |
15 |
Correct |
48 ms |
548 KB |
Output is correct |
16 |
Correct |
62 ms |
572 KB |
Output is correct |
17 |
Correct |
114 ms |
548 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
872 ms |
416 KB |
Output is correct |
2 |
Correct |
606 ms |
532 KB |
Output is correct |
3 |
Correct |
669 ms |
420 KB |
Output is correct |
4 |
Correct |
3 ms |
488 KB |
Output is correct |
5 |
Correct |
4 ms |
472 KB |
Output is correct |
6 |
Correct |
1 ms |
492 KB |
Output is correct |
7 |
Correct |
740 ms |
416 KB |
Output is correct |
8 |
Correct |
995 ms |
416 KB |
Output is correct |
9 |
Correct |
782 ms |
516 KB |
Output is correct |
10 |
Correct |
699 ms |
532 KB |
Output is correct |
11 |
Correct |
5 ms |
492 KB |
Output is correct |
12 |
Correct |
6 ms |
492 KB |
Output is correct |
13 |
Correct |
5 ms |
492 KB |
Output is correct |
14 |
Correct |
5 ms |
624 KB |
Output is correct |
15 |
Correct |
2 ms |
492 KB |
Output is correct |
16 |
Correct |
530 ms |
420 KB |
Output is correct |
17 |
Correct |
641 ms |
532 KB |
Output is correct |
18 |
Correct |
651 ms |
532 KB |
Output is correct |
19 |
Correct |
578 ms |
524 KB |
Output is correct |
20 |
Correct |
464 ms |
516 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
611 ms |
652 KB |
Output is correct |
2 |
Correct |
501 ms |
544 KB |
Output is correct |
3 |
Correct |
802 ms |
524 KB |
Output is correct |
4 |
Correct |
712 ms |
520 KB |
Output is correct |
5 |
Correct |
630 ms |
528 KB |
Output is correct |
6 |
Correct |
448 ms |
544 KB |
Output is correct |
7 |
Correct |
485 ms |
508 KB |
Output is correct |
8 |
Correct |
3 ms |
620 KB |
Output is correct |
9 |
Correct |
5 ms |
492 KB |
Output is correct |
10 |
Correct |
2 ms |
464 KB |
Output is correct |
11 |
Correct |
443 ms |
548 KB |
Output is correct |
12 |
Correct |
641 ms |
548 KB |
Output is correct |
13 |
Correct |
948 ms |
516 KB |
Output is correct |
14 |
Correct |
703 ms |
420 KB |
Output is correct |
15 |
Correct |
460 ms |
420 KB |
Output is correct |
16 |
Correct |
382 ms |
548 KB |
Output is correct |
17 |
Correct |
524 ms |
416 KB |
Output is correct |
18 |
Correct |
429 ms |
656 KB |
Output is correct |
19 |
Correct |
436 ms |
780 KB |
Output is correct |
20 |
Correct |
482 ms |
544 KB |
Output is correct |
21 |
Correct |
50 ms |
544 KB |
Output is correct |
22 |
Correct |
63 ms |
724 KB |
Output is correct |
23 |
Correct |
109 ms |
672 KB |
Output is correct |
24 |
Correct |
5 ms |
512 KB |
Output is correct |
25 |
Correct |
4 ms |
504 KB |
Output is correct |
26 |
Correct |
3 ms |
500 KB |
Output is correct |
27 |
Correct |
3 ms |
492 KB |
Output is correct |
28 |
Correct |
2 ms |
492 KB |
Output is correct |
29 |
Correct |
447 ms |
524 KB |
Output is correct |
30 |
Correct |
531 ms |
548 KB |
Output is correct |
31 |
Correct |
522 ms |
420 KB |
Output is correct |
32 |
Correct |
636 ms |
416 KB |
Output is correct |
33 |
Correct |
413 ms |
416 KB |
Output is correct |
34 |
Correct |
318 ms |
644 KB |
Output is correct |
35 |
Correct |
425 ms |
724 KB |
Output is correct |
36 |
Correct |
483 ms |
784 KB |
Output is correct |
37 |
Correct |
440 ms |
528 KB |
Output is correct |
38 |
Correct |
479 ms |
728 KB |
Output is correct |
39 |
Correct |
465 ms |
656 KB |
Output is correct |
40 |
Correct |
457 ms |
784 KB |
Output is correct |
41 |
Correct |
482 ms |
776 KB |
Output is correct |
42 |
Correct |
74 ms |
740 KB |
Output is correct |
43 |
Correct |
109 ms |
672 KB |
Output is correct |
44 |
Correct |
125 ms |
632 KB |
Output is correct |
45 |
Correct |
192 ms |
544 KB |
Output is correct |
46 |
Correct |
300 ms |
612 KB |
Output is correct |
47 |
Correct |
297 ms |
536 KB |
Output is correct |
48 |
Correct |
68 ms |
700 KB |
Output is correct |
49 |
Correct |
64 ms |
728 KB |
Output is correct |