Submission #581892

# Submission time Handle Problem Language Result Execution time Memory
581892 2022-06-23T07:45:18 Z joelau Stations (IOI20_stations) C++14
100 / 100
1319 ms 860 KB
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> lst[1005], ans;
int cnt = 0;

void dfs (int x, int p, int d) {
	if (d % 2 == 0) ans[x] = cnt++;
	for (int v: lst[x]) if (v != p) dfs(v,x,d+1);
	if (d % 2 == 1) ans[x] = cnt++;
}

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	for (int i = 0; i < n; ++i) lst[i].clear();
	for (int i = 0; i < n-1; ++i) lst[u[i]].push_back(v[i]), lst[v[i]].push_back(u[i]);
	ans.assign(n,0);
	cnt = 0;
	dfs(0,-1,0);
	return ans;
}

int find_next_station(int s, int t, vector<int> c) {
	if (s < c[0]) {
		if (t < s || t > c.back()) return c.back();
		else return *lower_bound(c.begin(),c.end(),t);
	}
	else {
		if (t < c.front() || t > s) return c.front();
		else return *prev(upper_bound(c.begin(),c.end(),t));
	}
}
# Verdict Execution time Memory Grader output
1 Correct 553 ms 664 KB Output is correct
2 Correct 485 ms 536 KB Output is correct
3 Correct 883 ms 508 KB Output is correct
4 Correct 534 ms 416 KB Output is correct
5 Correct 595 ms 528 KB Output is correct
6 Correct 470 ms 640 KB Output is correct
7 Correct 420 ms 548 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 5 ms 500 KB Output is correct
10 Correct 1 ms 500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 476 ms 532 KB Output is correct
2 Correct 541 ms 540 KB Output is correct
3 Correct 858 ms 416 KB Output is correct
4 Correct 586 ms 416 KB Output is correct
5 Correct 513 ms 416 KB Output is correct
6 Correct 431 ms 532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 536 ms 660 KB Output is correct
2 Correct 446 ms 728 KB Output is correct
3 Correct 859 ms 524 KB Output is correct
4 Correct 589 ms 532 KB Output is correct
5 Correct 558 ms 420 KB Output is correct
6 Correct 465 ms 540 KB Output is correct
7 Correct 455 ms 528 KB Output is correct
8 Correct 2 ms 500 KB Output is correct
9 Correct 5 ms 500 KB Output is correct
10 Correct 2 ms 568 KB Output is correct
11 Correct 624 ms 528 KB Output is correct
12 Correct 518 ms 660 KB Output is correct
13 Correct 451 ms 660 KB Output is correct
14 Correct 478 ms 528 KB Output is correct
15 Correct 62 ms 584 KB Output is correct
16 Correct 62 ms 556 KB Output is correct
17 Correct 93 ms 544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1081 ms 420 KB Output is correct
2 Correct 774 ms 528 KB Output is correct
3 Correct 674 ms 416 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 4 ms 500 KB Output is correct
6 Correct 1 ms 492 KB Output is correct
7 Correct 549 ms 416 KB Output is correct
8 Correct 1319 ms 420 KB Output is correct
9 Correct 719 ms 532 KB Output is correct
10 Correct 799 ms 524 KB Output is correct
11 Correct 5 ms 492 KB Output is correct
12 Correct 5 ms 492 KB Output is correct
13 Correct 5 ms 492 KB Output is correct
14 Correct 4 ms 492 KB Output is correct
15 Correct 2 ms 492 KB Output is correct
16 Correct 696 ms 420 KB Output is correct
17 Correct 496 ms 528 KB Output is correct
18 Correct 488 ms 536 KB Output is correct
19 Correct 560 ms 420 KB Output is correct
20 Correct 427 ms 416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 551 ms 548 KB Output is correct
2 Correct 461 ms 516 KB Output is correct
3 Correct 922 ms 420 KB Output is correct
4 Correct 597 ms 528 KB Output is correct
5 Correct 480 ms 524 KB Output is correct
6 Correct 428 ms 656 KB Output is correct
7 Correct 502 ms 524 KB Output is correct
8 Correct 3 ms 500 KB Output is correct
9 Correct 4 ms 500 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
11 Correct 430 ms 568 KB Output is correct
12 Correct 495 ms 552 KB Output is correct
13 Correct 881 ms 420 KB Output is correct
14 Correct 616 ms 416 KB Output is correct
15 Correct 537 ms 528 KB Output is correct
16 Correct 438 ms 544 KB Output is correct
17 Correct 626 ms 416 KB Output is correct
18 Correct 450 ms 652 KB Output is correct
19 Correct 509 ms 724 KB Output is correct
20 Correct 486 ms 548 KB Output is correct
21 Correct 59 ms 432 KB Output is correct
22 Correct 56 ms 572 KB Output is correct
23 Correct 83 ms 672 KB Output is correct
24 Correct 6 ms 500 KB Output is correct
25 Correct 3 ms 492 KB Output is correct
26 Correct 3 ms 496 KB Output is correct
27 Correct 2 ms 492 KB Output is correct
28 Correct 1 ms 500 KB Output is correct
29 Correct 430 ms 420 KB Output is correct
30 Correct 520 ms 556 KB Output is correct
31 Correct 410 ms 416 KB Output is correct
32 Correct 542 ms 420 KB Output is correct
33 Correct 481 ms 420 KB Output is correct
34 Correct 264 ms 544 KB Output is correct
35 Correct 414 ms 756 KB Output is correct
36 Correct 429 ms 768 KB Output is correct
37 Correct 401 ms 684 KB Output is correct
38 Correct 455 ms 700 KB Output is correct
39 Correct 475 ms 852 KB Output is correct
40 Correct 461 ms 640 KB Output is correct
41 Correct 434 ms 860 KB Output is correct
42 Correct 54 ms 544 KB Output is correct
43 Correct 107 ms 544 KB Output is correct
44 Correct 127 ms 544 KB Output is correct
45 Correct 168 ms 636 KB Output is correct
46 Correct 314 ms 536 KB Output is correct
47 Correct 347 ms 532 KB Output is correct
48 Correct 51 ms 684 KB Output is correct
49 Correct 60 ms 728 KB Output is correct