답안 #416062

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
416062 2021-06-01T21:27:07 Z SuhaibSawalha1 기지국 (IOI20_stations) C++17
100 / 100
1423 ms 776 KB
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
 
vector<vector<int>> adj;
vector<int> lab, in, out;
int dfst;
 
void dfs (int u = 0, int p = -1, int d = 0) {
	in[u] = dfst++;
	for (int v : adj[u]) {
		if (v ^ p) {
			dfs(v, u, d ^ 1);
		}
	}
	out[u] = dfst++;
	lab[u] = d ? in[u] : out[u];
}

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	adj.assign(n, {});
	lab.resize(n);
	in.resize(n);
	out.resize(n);
	dfst = 0;
	for (int i = 0; i < n - 1; ++i) {
		adj[u[i]].push_back(v[i]);
		adj[v[i]].push_back(u[i]);
	}
	dfs();
	vector<int> ii = lab;
	sort(lab.begin(), lab.end());
	for (int i = 0; i < n; ++i) {
		ii[i] = lower_bound(lab.begin(), lab.end(), ii[i]) - lab.begin();
	}
	return ii;
}

int find_next_station(int s, int t, vector<int> c) {
	if (c.size() == 1) {
		return c[0];
	}
	if (s < c[0]) { 
		if (t < s || t > c.back()) {
			return c.back();
		}
		return *lower_bound(c.begin(), c.end(), t);
	}
	else { 
		if (t > s || t < c[1]) {
			return c[0];
		}
		return *(upper_bound(c.begin(), c.end(), t) - 1);
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 681 ms 612 KB Output is correct
2 Correct 710 ms 628 KB Output is correct
3 Correct 1284 ms 492 KB Output is correct
4 Correct 960 ms 400 KB Output is correct
5 Correct 768 ms 468 KB Output is correct
6 Correct 737 ms 616 KB Output is correct
7 Correct 516 ms 608 KB Output is correct
8 Correct 5 ms 432 KB Output is correct
9 Correct 9 ms 448 KB Output is correct
10 Correct 2 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 537 ms 584 KB Output is correct
2 Correct 628 ms 544 KB Output is correct
3 Correct 1423 ms 496 KB Output is correct
4 Correct 844 ms 468 KB Output is correct
5 Correct 853 ms 484 KB Output is correct
6 Correct 617 ms 628 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 770 ms 632 KB Output is correct
2 Correct 608 ms 596 KB Output is correct
3 Correct 1232 ms 468 KB Output is correct
4 Correct 829 ms 400 KB Output is correct
5 Correct 607 ms 488 KB Output is correct
6 Correct 659 ms 604 KB Output is correct
7 Correct 593 ms 612 KB Output is correct
8 Correct 3 ms 468 KB Output is correct
9 Correct 6 ms 420 KB Output is correct
10 Correct 3 ms 472 KB Output is correct
11 Correct 865 ms 400 KB Output is correct
12 Correct 549 ms 696 KB Output is correct
13 Correct 700 ms 640 KB Output is correct
14 Correct 476 ms 480 KB Output is correct
15 Correct 68 ms 400 KB Output is correct
16 Correct 71 ms 532 KB Output is correct
17 Correct 171 ms 528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1031 ms 400 KB Output is correct
2 Correct 723 ms 468 KB Output is correct
3 Correct 838 ms 560 KB Output is correct
4 Correct 4 ms 468 KB Output is correct
5 Correct 6 ms 468 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 813 ms 492 KB Output is correct
8 Correct 1156 ms 560 KB Output is correct
9 Correct 913 ms 524 KB Output is correct
10 Correct 801 ms 464 KB Output is correct
11 Correct 8 ms 468 KB Output is correct
12 Correct 5 ms 468 KB Output is correct
13 Correct 4 ms 420 KB Output is correct
14 Correct 4 ms 420 KB Output is correct
15 Correct 3 ms 432 KB Output is correct
16 Correct 590 ms 492 KB Output is correct
17 Correct 719 ms 544 KB Output is correct
18 Correct 700 ms 492 KB Output is correct
19 Correct 631 ms 400 KB Output is correct
20 Correct 645 ms 488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 664 ms 668 KB Output is correct
2 Correct 519 ms 608 KB Output is correct
3 Correct 1097 ms 528 KB Output is correct
4 Correct 830 ms 484 KB Output is correct
5 Correct 814 ms 508 KB Output is correct
6 Correct 458 ms 636 KB Output is correct
7 Correct 538 ms 476 KB Output is correct
8 Correct 4 ms 468 KB Output is correct
9 Correct 8 ms 468 KB Output is correct
10 Correct 2 ms 464 KB Output is correct
11 Correct 547 ms 480 KB Output is correct
12 Correct 681 ms 540 KB Output is correct
13 Correct 897 ms 496 KB Output is correct
14 Correct 1047 ms 532 KB Output is correct
15 Correct 622 ms 400 KB Output is correct
16 Correct 514 ms 488 KB Output is correct
17 Correct 710 ms 400 KB Output is correct
18 Correct 541 ms 692 KB Output is correct
19 Correct 736 ms 692 KB Output is correct
20 Correct 563 ms 476 KB Output is correct
21 Correct 73 ms 400 KB Output is correct
22 Correct 69 ms 528 KB Output is correct
23 Correct 110 ms 528 KB Output is correct
24 Correct 11 ms 468 KB Output is correct
25 Correct 4 ms 420 KB Output is correct
26 Correct 6 ms 468 KB Output is correct
27 Correct 3 ms 468 KB Output is correct
28 Correct 3 ms 516 KB Output is correct
29 Correct 703 ms 400 KB Output is correct
30 Correct 700 ms 484 KB Output is correct
31 Correct 588 ms 488 KB Output is correct
32 Correct 515 ms 508 KB Output is correct
33 Correct 608 ms 572 KB Output is correct
34 Correct 369 ms 648 KB Output is correct
35 Correct 523 ms 612 KB Output is correct
36 Correct 589 ms 728 KB Output is correct
37 Correct 516 ms 696 KB Output is correct
38 Correct 509 ms 668 KB Output is correct
39 Correct 627 ms 672 KB Output is correct
40 Correct 621 ms 688 KB Output is correct
41 Correct 676 ms 568 KB Output is correct
42 Correct 70 ms 584 KB Output is correct
43 Correct 118 ms 484 KB Output is correct
44 Correct 155 ms 596 KB Output is correct
45 Correct 178 ms 488 KB Output is correct
46 Correct 346 ms 492 KB Output is correct
47 Correct 390 ms 484 KB Output is correct
48 Correct 94 ms 776 KB Output is correct
49 Correct 70 ms 624 KB Output is correct