답안 #831890

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
831890 2023-08-20T16:55:21 Z Jasonwei 기지국 (IOI20_stations) C++14
100 / 100
803 ms 724 KB
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
vector <vector <int> > g;
int cnt;
vector <int> labels;
void dfs (int x, int fa, bool b) {
	if (b) labels[x] = cnt ++;
	for (int t : g[x]) {
		if (t == fa) continue;
		dfs (t, x, ! b);
	}
	if (! b) labels[x] = cnt ++;
}
vector <int> label (int n, int k, vector <int> u, vector<int> v) {
	cnt = 0;
	g.clear (), g.resize (n);
	for (int i = 0; i < n - 1; i++) g[u[i]].push_back (v[i]), g[v[i]].push_back (u[i]);
	labels.assign (n, -1);
	dfs (0, -1, true);
	return labels;
}
int find_next_station (int s, int t, vector <int> c) {
	int n = (int) c.size ();
	if (s < c[0]) {
		if (t < s) return c[n - 1];
		for (int i = 0; i < n - 1; i ++) {
			if (t <= c[i]) return c[i];
		}
		return c[n - 1];
	} else {
		if (t > s) return c[0];
		for (int i = n - 1; i > 0; i --) {
			if (c[i] <= t) return c[i];
		}
		return c[0];
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 432 ms 620 KB Output is correct
2 Correct 384 ms 628 KB Output is correct
3 Correct 624 ms 416 KB Output is correct
4 Correct 473 ms 500 KB Output is correct
5 Correct 429 ms 504 KB Output is correct
6 Correct 462 ms 628 KB Output is correct
7 Correct 427 ms 628 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 2 ms 500 KB Output is correct
10 Correct 0 ms 500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 322 ms 628 KB Output is correct
2 Correct 320 ms 548 KB Output is correct
3 Correct 669 ms 544 KB Output is correct
4 Correct 497 ms 416 KB Output is correct
5 Correct 521 ms 416 KB Output is correct
6 Correct 393 ms 544 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 509 ms 672 KB Output is correct
2 Correct 260 ms 676 KB Output is correct
3 Correct 614 ms 508 KB Output is correct
4 Correct 468 ms 420 KB Output is correct
5 Correct 567 ms 508 KB Output is correct
6 Correct 400 ms 544 KB Output is correct
7 Correct 318 ms 548 KB Output is correct
8 Correct 1 ms 504 KB Output is correct
9 Correct 3 ms 504 KB Output is correct
10 Correct 0 ms 500 KB Output is correct
11 Correct 387 ms 504 KB Output is correct
12 Correct 313 ms 632 KB Output is correct
13 Correct 420 ms 544 KB Output is correct
14 Correct 443 ms 500 KB Output is correct
15 Correct 39 ms 492 KB Output is correct
16 Correct 61 ms 544 KB Output is correct
17 Correct 94 ms 544 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 625 ms 416 KB Output is correct
2 Correct 493 ms 556 KB Output is correct
3 Correct 475 ms 508 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 2 ms 500 KB Output is correct
6 Correct 1 ms 500 KB Output is correct
7 Correct 479 ms 500 KB Output is correct
8 Correct 674 ms 416 KB Output is correct
9 Correct 406 ms 420 KB Output is correct
10 Correct 467 ms 416 KB Output is correct
11 Correct 2 ms 496 KB Output is correct
12 Correct 2 ms 500 KB Output is correct
13 Correct 4 ms 492 KB Output is correct
14 Correct 2 ms 488 KB Output is correct
15 Correct 0 ms 492 KB Output is correct
16 Correct 384 ms 504 KB Output is correct
17 Correct 430 ms 504 KB Output is correct
18 Correct 474 ms 508 KB Output is correct
19 Correct 387 ms 420 KB Output is correct
20 Correct 317 ms 420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 400 ms 628 KB Output is correct
2 Correct 351 ms 672 KB Output is correct
3 Correct 532 ms 420 KB Output is correct
4 Correct 411 ms 416 KB Output is correct
5 Correct 488 ms 500 KB Output is correct
6 Correct 354 ms 544 KB Output is correct
7 Correct 411 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 492 KB Output is correct
11 Correct 362 ms 640 KB Output is correct
12 Correct 480 ms 508 KB Output is correct
13 Correct 803 ms 508 KB Output is correct
14 Correct 364 ms 420 KB Output is correct
15 Correct 336 ms 416 KB Output is correct
16 Correct 307 ms 572 KB Output is correct
17 Correct 402 ms 420 KB Output is correct
18 Correct 427 ms 716 KB Output is correct
19 Correct 341 ms 628 KB Output is correct
20 Correct 370 ms 548 KB Output is correct
21 Correct 39 ms 492 KB Output is correct
22 Correct 44 ms 544 KB Output is correct
23 Correct 62 ms 508 KB Output is correct
24 Correct 5 ms 492 KB Output is correct
25 Correct 3 ms 492 KB Output is correct
26 Correct 3 ms 500 KB Output is correct
27 Correct 1 ms 492 KB Output is correct
28 Correct 1 ms 492 KB Output is correct
29 Correct 321 ms 428 KB Output is correct
30 Correct 423 ms 416 KB Output is correct
31 Correct 328 ms 508 KB Output is correct
32 Correct 433 ms 420 KB Output is correct
33 Correct 350 ms 420 KB Output is correct
34 Correct 322 ms 676 KB Output is correct
35 Correct 361 ms 588 KB Output is correct
36 Correct 330 ms 676 KB Output is correct
37 Correct 424 ms 720 KB Output is correct
38 Correct 324 ms 544 KB Output is correct
39 Correct 321 ms 720 KB Output is correct
40 Correct 418 ms 628 KB Output is correct
41 Correct 400 ms 632 KB Output is correct
42 Correct 48 ms 624 KB Output is correct
43 Correct 78 ms 532 KB Output is correct
44 Correct 85 ms 672 KB Output is correct
45 Correct 114 ms 544 KB Output is correct
46 Correct 226 ms 544 KB Output is correct
47 Correct 204 ms 504 KB Output is correct
48 Correct 43 ms 724 KB Output is correct
49 Correct 35 ms 692 KB Output is correct