답안 #978926

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
978926 2024-05-10T03:37:54 Z happypotato 기지국 (IOI20_stations) C++17
100 / 100
594 ms 1464 KB
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back

vector<int> label(int n, int k, vector<int> U, vector<int> V) {
	vector<vector<int>> adj(n);
	for (int i = 0; i < n - 1; i++) {
		adj[U[i]].pb(V[i]);
		adj[V[i]].pb(U[i]);
	}
	vector<int> res(n);
	int tt = 0;

	auto dfs = [&](auto&& self, int u = 0, int par = -1, bool flag = false) -> void {
		if (!flag) res[u] = ++tt;
		for (int v : adj[u]) {
			if (v == par) continue;
			self(self, v, u, flag ^ 1);
		}
		if (flag) res[u] = ++tt;
	};

	dfs(dfs);
	return res;
}

int find_next_station(int s, int t, vector<int> c) {
	if (c.size() == 1) return c.front();
	c.pb(s);
	sort(c.begin(), c.end());
	if (c.back() == s) {
		for (int i = 1; i < (int)(c.size()) - 1; i++) {
			if (c[i] <= t && t < c[i + 1]) return c[i];
		}
		return c.front();
	} else if (c.front() == s) {
		for (int i = 1; i < (int)(c.size()) - 1; i++) {
			if (c[i - 1] < t && t <= c[i]) return c[i];
		}
		return c.back();
	} else throw runtime_error("wrong construction");
}
# 결과 실행 시간 메모리 Grader output
1 Correct 381 ms 888 KB Output is correct
2 Correct 293 ms 884 KB Output is correct
3 Correct 594 ms 684 KB Output is correct
4 Correct 453 ms 684 KB Output is correct
5 Correct 397 ms 684 KB Output is correct
6 Correct 309 ms 880 KB Output is correct
7 Correct 293 ms 684 KB Output is correct
8 Correct 1 ms 856 KB Output is correct
9 Correct 2 ms 768 KB Output is correct
10 Correct 1 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 300 ms 1024 KB Output is correct
2 Correct 327 ms 796 KB Output is correct
3 Correct 538 ms 768 KB Output is correct
4 Correct 387 ms 680 KB Output is correct
5 Correct 348 ms 684 KB Output is correct
6 Correct 273 ms 684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 321 ms 880 KB Output is correct
2 Correct 302 ms 1052 KB Output is correct
3 Correct 549 ms 684 KB Output is correct
4 Correct 445 ms 684 KB Output is correct
5 Correct 363 ms 684 KB Output is correct
6 Correct 307 ms 872 KB Output is correct
7 Correct 296 ms 684 KB Output is correct
8 Correct 2 ms 992 KB Output is correct
9 Correct 2 ms 768 KB Output is correct
10 Correct 0 ms 768 KB Output is correct
11 Correct 374 ms 940 KB Output is correct
12 Correct 342 ms 1124 KB Output is correct
13 Correct 293 ms 1148 KB Output is correct
14 Correct 274 ms 684 KB Output is correct
15 Correct 34 ms 768 KB Output is correct
16 Correct 38 ms 904 KB Output is correct
17 Correct 69 ms 848 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 579 ms 684 KB Output is correct
2 Correct 464 ms 684 KB Output is correct
3 Correct 394 ms 684 KB Output is correct
4 Correct 1 ms 776 KB Output is correct
5 Correct 2 ms 768 KB Output is correct
6 Correct 0 ms 768 KB Output is correct
7 Correct 391 ms 684 KB Output is correct
8 Correct 564 ms 684 KB Output is correct
9 Correct 427 ms 684 KB Output is correct
10 Correct 391 ms 684 KB Output is correct
11 Correct 3 ms 764 KB Output is correct
12 Correct 3 ms 764 KB Output is correct
13 Correct 2 ms 768 KB Output is correct
14 Correct 3 ms 768 KB Output is correct
15 Correct 0 ms 768 KB Output is correct
16 Correct 318 ms 684 KB Output is correct
17 Correct 296 ms 684 KB Output is correct
18 Correct 347 ms 684 KB Output is correct
19 Correct 324 ms 684 KB Output is correct
20 Correct 340 ms 684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 358 ms 888 KB Output is correct
2 Correct 321 ms 880 KB Output is correct
3 Correct 590 ms 684 KB Output is correct
4 Correct 396 ms 684 KB Output is correct
5 Correct 365 ms 684 KB Output is correct
6 Correct 309 ms 864 KB Output is correct
7 Correct 276 ms 684 KB Output is correct
8 Correct 1 ms 768 KB Output is correct
9 Correct 3 ms 768 KB Output is correct
10 Correct 1 ms 768 KB Output is correct
11 Correct 300 ms 852 KB Output is correct
12 Correct 398 ms 828 KB Output is correct
13 Correct 510 ms 684 KB Output is correct
14 Correct 449 ms 732 KB Output is correct
15 Correct 482 ms 684 KB Output is correct
16 Correct 288 ms 684 KB Output is correct
17 Correct 386 ms 684 KB Output is correct
18 Correct 307 ms 948 KB Output is correct
19 Correct 302 ms 1132 KB Output is correct
20 Correct 292 ms 684 KB Output is correct
21 Correct 37 ms 964 KB Output is correct
22 Correct 44 ms 1000 KB Output is correct
23 Correct 72 ms 1360 KB Output is correct
24 Correct 4 ms 764 KB Output is correct
25 Correct 3 ms 768 KB Output is correct
26 Correct 2 ms 1024 KB Output is correct
27 Correct 3 ms 768 KB Output is correct
28 Correct 1 ms 768 KB Output is correct
29 Correct 321 ms 684 KB Output is correct
30 Correct 306 ms 684 KB Output is correct
31 Correct 305 ms 844 KB Output is correct
32 Correct 355 ms 1096 KB Output is correct
33 Correct 358 ms 684 KB Output is correct
34 Correct 192 ms 872 KB Output is correct
35 Correct 293 ms 1384 KB Output is correct
36 Correct 294 ms 1136 KB Output is correct
37 Correct 272 ms 1376 KB Output is correct
38 Correct 297 ms 1448 KB Output is correct
39 Correct 301 ms 1224 KB Output is correct
40 Correct 292 ms 1368 KB Output is correct
41 Correct 299 ms 1372 KB Output is correct
42 Correct 39 ms 836 KB Output is correct
43 Correct 64 ms 916 KB Output is correct
44 Correct 80 ms 940 KB Output is correct
45 Correct 112 ms 912 KB Output is correct
46 Correct 211 ms 840 KB Output is correct
47 Correct 186 ms 864 KB Output is correct
48 Correct 36 ms 1196 KB Output is correct
49 Correct 34 ms 1464 KB Output is correct