답안 #800613

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
800613 2023-08-01T16:44:41 Z Liudas 기지국 (IOI20_stations) C++17
100 / 100
812 ms 764 KB
#include <algorithm>
#define MAXN 1000

int cnt;
std::vector<int> adj[MAXN], labels;

void dfs(int v, int p, int d) {
	if(!d) labels[v] = cnt++;
	for (int i : adj[v]) if (i != p) dfs(i, v, d ^ 1);
	if(d) labels[v] = cnt++;
}

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	cnt = 0;
	for (int i = 0; i < n; i++) {
		adj[i].clear();
	}
	for (int i = 0; i < n - 1; i++) {
		adj[u[i]].push_back(v[i]);
		adj[v[i]].push_back(u[i]);
	}
	labels.resize(n);
	dfs(0, -1, 0);
	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
	if (s < c[0]) {
		if (t < s || t >= c.back()) return c.back();
		return *std::lower_bound(c.begin(), c.end(), t);
	}
	if (t > s || t <= c[0]) return c[0];
	return *--std::upper_bound(c.begin(), c.end(), t);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 494 ms 644 KB Output is correct
2 Correct 341 ms 548 KB Output is correct
3 Correct 775 ms 492 KB Output is correct
4 Correct 522 ms 516 KB Output is correct
5 Correct 498 ms 416 KB Output is correct
6 Correct 375 ms 716 KB Output is correct
7 Correct 463 ms 548 KB Output is correct
8 Correct 1 ms 492 KB Output is correct
9 Correct 3 ms 492 KB Output is correct
10 Correct 0 ms 496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 329 ms 516 KB Output is correct
2 Correct 358 ms 512 KB Output is correct
3 Correct 706 ms 416 KB Output is correct
4 Correct 479 ms 512 KB Output is correct
5 Correct 527 ms 516 KB Output is correct
6 Correct 319 ms 564 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 524 ms 664 KB Output is correct
2 Correct 338 ms 636 KB Output is correct
3 Correct 685 ms 512 KB Output is correct
4 Correct 555 ms 580 KB Output is correct
5 Correct 512 ms 512 KB Output is correct
6 Correct 360 ms 644 KB Output is correct
7 Correct 399 ms 512 KB Output is correct
8 Correct 1 ms 500 KB Output is correct
9 Correct 3 ms 492 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
11 Correct 534 ms 524 KB Output is correct
12 Correct 447 ms 744 KB Output is correct
13 Correct 325 ms 740 KB Output is correct
14 Correct 396 ms 512 KB Output is correct
15 Correct 33 ms 492 KB Output is correct
16 Correct 60 ms 620 KB Output is correct
17 Correct 102 ms 544 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 785 ms 416 KB Output is correct
2 Correct 522 ms 420 KB Output is correct
3 Correct 491 ms 484 KB Output is correct
4 Correct 3 ms 492 KB Output is correct
5 Correct 2 ms 500 KB Output is correct
6 Correct 0 ms 492 KB Output is correct
7 Correct 563 ms 512 KB Output is correct
8 Correct 710 ms 416 KB Output is correct
9 Correct 592 ms 416 KB Output is correct
10 Correct 528 ms 416 KB Output is correct
11 Correct 3 ms 492 KB Output is correct
12 Correct 3 ms 492 KB Output is correct
13 Correct 3 ms 440 KB Output is correct
14 Correct 2 ms 492 KB Output is correct
15 Correct 1 ms 492 KB Output is correct
16 Correct 471 ms 656 KB Output is correct
17 Correct 475 ms 516 KB Output is correct
18 Correct 364 ms 420 KB Output is correct
19 Correct 499 ms 416 KB Output is correct
20 Correct 358 ms 416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 494 ms 548 KB Output is correct
2 Correct 386 ms 696 KB Output is correct
3 Correct 812 ms 420 KB Output is correct
4 Correct 459 ms 500 KB Output is correct
5 Correct 474 ms 512 KB Output is correct
6 Correct 316 ms 636 KB Output is correct
7 Correct 387 ms 520 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 3 ms 492 KB Output is correct
10 Correct 0 ms 500 KB Output is correct
11 Correct 314 ms 516 KB Output is correct
12 Correct 508 ms 544 KB Output is correct
13 Correct 733 ms 516 KB Output is correct
14 Correct 395 ms 420 KB Output is correct
15 Correct 489 ms 516 KB Output is correct
16 Correct 406 ms 512 KB Output is correct
17 Correct 414 ms 516 KB Output is correct
18 Correct 430 ms 604 KB Output is correct
19 Correct 310 ms 544 KB Output is correct
20 Correct 314 ms 544 KB Output is correct
21 Correct 34 ms 492 KB Output is correct
22 Correct 54 ms 628 KB Output is correct
23 Correct 96 ms 572 KB Output is correct
24 Correct 2 ms 492 KB Output is correct
25 Correct 3 ms 492 KB Output is correct
26 Correct 3 ms 488 KB Output is correct
27 Correct 2 ms 492 KB Output is correct
28 Correct 1 ms 456 KB Output is correct
29 Correct 481 ms 516 KB Output is correct
30 Correct 432 ms 516 KB Output is correct
31 Correct 471 ms 420 KB Output is correct
32 Correct 460 ms 416 KB Output is correct
33 Correct 315 ms 416 KB Output is correct
34 Correct 223 ms 648 KB Output is correct
35 Correct 307 ms 648 KB Output is correct
36 Correct 305 ms 672 KB Output is correct
37 Correct 442 ms 544 KB Output is correct
38 Correct 386 ms 544 KB Output is correct
39 Correct 336 ms 636 KB Output is correct
40 Correct 343 ms 764 KB Output is correct
41 Correct 376 ms 740 KB Output is correct
42 Correct 53 ms 560 KB Output is correct
43 Correct 93 ms 584 KB Output is correct
44 Correct 90 ms 640 KB Output is correct
45 Correct 123 ms 548 KB Output is correct
46 Correct 256 ms 544 KB Output is correct
47 Correct 185 ms 548 KB Output is correct
48 Correct 41 ms 596 KB Output is correct
49 Correct 43 ms 712 KB Output is correct