답안 #422393

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
422393 2021-06-10T05:39:00 Z Mazaalai 기지국 (IOI20_stations) C++14
100 / 100
1204 ms 776 KB
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
int val;
const int N = 1005;
vector <int> labels;
vector <vector <int> > paths(N);
void traversal(int pos, int par, int order) {
	if (order) labels[pos] = val++;
	for (auto el : paths[pos]) {
		if (el == par) continue;
		traversal(el, pos, (order^1));
	}
	if (!order) labels[pos] = val++;
}
vector <int> label(int n, int k, vector <int> u, vector <int> v) {
	val = 0;
	labels.resize(n);
	for (int i = 0; i < n; i++) paths[i].clear();
	for (int i = 0; i < n - 1; i++) {
		int a = u[i], b = v[i];
		paths[a].push_back(b);
		paths[b].push_back(a);
	}
	traversal(0, 0, 0);
	// for (int i = 0; i < n; i++) cout << i << ": " << labels[i] << '\n';
	return labels;
}

int find_next_station(int a, int b, vector <int> adj) {
	int st, end, sz = adj.size(), ans;
	if (sz == 1) return adj[0];
	for (auto el : adj) if (el == b) return b;
	if (adj[0] > a) {
		st = a;
		end = adj[sz-2];
		if (st <= b && b <= end) {
			ans = *lower_bound(adj.begin(), adj.end(), b);
		} else {
			ans = adj[sz-1];
		}
	} else {
		end = a;
		st = adj[1];
		if (st <= b && b <= end) {
			ans = *(--lower_bound(adj.begin(), adj.end(), b));
		} else {
			ans = adj[0];
		}
	}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 649 ms 632 KB Output is correct
2 Correct 518 ms 636 KB Output is correct
3 Correct 1022 ms 400 KB Output is correct
4 Correct 866 ms 400 KB Output is correct
5 Correct 649 ms 492 KB Output is correct
6 Correct 430 ms 532 KB Output is correct
7 Correct 570 ms 528 KB Output is correct
8 Correct 2 ms 476 KB Output is correct
9 Correct 4 ms 468 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 584 ms 548 KB Output is correct
2 Correct 742 ms 584 KB Output is correct
3 Correct 1204 ms 400 KB Output is correct
4 Correct 777 ms 400 KB Output is correct
5 Correct 749 ms 512 KB Output is correct
6 Correct 531 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 592 ms 656 KB Output is correct
2 Correct 444 ms 520 KB Output is correct
3 Correct 1025 ms 492 KB Output is correct
4 Correct 754 ms 400 KB Output is correct
5 Correct 703 ms 648 KB Output is correct
6 Correct 475 ms 504 KB Output is correct
7 Correct 537 ms 508 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 492 KB Output is correct
11 Correct 637 ms 508 KB Output is correct
12 Correct 512 ms 628 KB Output is correct
13 Correct 649 ms 624 KB Output is correct
14 Correct 542 ms 528 KB Output is correct
15 Correct 66 ms 468 KB Output is correct
16 Correct 72 ms 528 KB Output is correct
17 Correct 133 ms 684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1055 ms 400 KB Output is correct
2 Correct 763 ms 400 KB Output is correct
3 Correct 648 ms 400 KB Output is correct
4 Correct 3 ms 468 KB Output is correct
5 Correct 5 ms 468 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 711 ms 400 KB Output is correct
8 Correct 970 ms 512 KB Output is correct
9 Correct 805 ms 404 KB Output is correct
10 Correct 797 ms 400 KB Output is correct
11 Correct 7 ms 480 KB Output is correct
12 Correct 7 ms 468 KB Output is correct
13 Correct 5 ms 468 KB Output is correct
14 Correct 5 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 590 ms 512 KB Output is correct
17 Correct 666 ms 400 KB Output is correct
18 Correct 548 ms 404 KB Output is correct
19 Correct 557 ms 400 KB Output is correct
20 Correct 582 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 593 ms 640 KB Output is correct
2 Correct 544 ms 516 KB Output is correct
3 Correct 871 ms 400 KB Output is correct
4 Correct 768 ms 400 KB Output is correct
5 Correct 907 ms 416 KB Output is correct
6 Correct 462 ms 632 KB Output is correct
7 Correct 616 ms 512 KB Output is correct
8 Correct 3 ms 468 KB Output is correct
9 Correct 5 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 570 ms 492 KB Output is correct
12 Correct 727 ms 528 KB Output is correct
13 Correct 1196 ms 492 KB Output is correct
14 Correct 683 ms 516 KB Output is correct
15 Correct 707 ms 400 KB Output is correct
16 Correct 523 ms 508 KB Output is correct
17 Correct 798 ms 508 KB Output is correct
18 Correct 497 ms 616 KB Output is correct
19 Correct 715 ms 600 KB Output is correct
20 Correct 566 ms 512 KB Output is correct
21 Correct 57 ms 420 KB Output is correct
22 Correct 106 ms 528 KB Output is correct
23 Correct 119 ms 504 KB Output is correct
24 Correct 7 ms 468 KB Output is correct
25 Correct 7 ms 464 KB Output is correct
26 Correct 5 ms 468 KB Output is correct
27 Correct 5 ms 464 KB Output is correct
28 Correct 2 ms 468 KB Output is correct
29 Correct 549 ms 520 KB Output is correct
30 Correct 638 ms 512 KB Output is correct
31 Correct 623 ms 508 KB Output is correct
32 Correct 573 ms 400 KB Output is correct
33 Correct 588 ms 400 KB Output is correct
34 Correct 390 ms 508 KB Output is correct
35 Correct 515 ms 756 KB Output is correct
36 Correct 558 ms 744 KB Output is correct
37 Correct 465 ms 504 KB Output is correct
38 Correct 523 ms 640 KB Output is correct
39 Correct 541 ms 752 KB Output is correct
40 Correct 503 ms 776 KB Output is correct
41 Correct 550 ms 608 KB Output is correct
42 Correct 68 ms 532 KB Output is correct
43 Correct 133 ms 528 KB Output is correct
44 Correct 134 ms 528 KB Output is correct
45 Correct 196 ms 528 KB Output is correct
46 Correct 312 ms 528 KB Output is correct
47 Correct 389 ms 512 KB Output is correct
48 Correct 73 ms 748 KB Output is correct
49 Correct 57 ms 772 KB Output is correct