답안 #935146

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
935146 2024-02-28T17:51:47 Z MinaRagy06 자매 도시 (APIO20_swap) C++17
37 / 100
2000 ms 13032 KB
#include <bits/stdc++.h>
#ifdef MINA
#include "grader.cpp"
#endif
using namespace std;
#define ll long long
 
const int N = 200'005;
int n, m;
array<int, 3> e[N];
void init(int _n, int _m, vector<int> u, vector<int> v, vector<int> w) {
	n = _n, m = _m;
	for (int i = 0; i < m; i++) {
		e[i] = {u[i], v[i], w[i]};
	}
	sort(e, e + m, [&] (array<int, 3> x, array<int, 3> y) {return x[2] < y[2];});
}
int par[N], sz[N], deg[N], mx[N], cnt[N];
int find(int u) {
	if (par[u] == u) {
		return u;
	}
	return par[u] = find(par[u]);
}
void join(int u, int v) {
	int du = ++deg[u], dv = ++deg[v];
	u = find(u), v = find(v);
	mx[u] = max(mx[u], du);
	mx[v] = max(mx[v], dv);
	cnt[u]++;
	if (u == v) return;
	if (sz[u] < sz[v]) swap(u, v);
	par[v] = u;
	sz[u] += sz[v];
	cnt[u] += cnt[v];
	mx[u] = max(mx[u], mx[v]);
}
int getMinimumFuelCapacity(int x, int y) {
	int l = 0, r = m - 1;
	while (l <= r) {
		int md = ((l + r) >> 1);
		for (int i = 0; i < n; i++) {
			par[i] = i;
			sz[i] = 1;
			deg[i] = 0;
			mx[i] = 0;
			cnt[i] = 0;
		}
		for (int j = 0; j <= md; j++) {
			join(e[j][0], e[j][1]);
		}
		if (find(x) == find(y) && (mx[find(x)] > 2 || cnt[find(x)] >= sz[find(x)])) {
			r = md - 1;
		} else {
			l = md + 1;
		}
	}
	if (l == m) {
		return -1;
	}
	return e[l][2];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4544 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 77 ms 7216 KB Output is correct
10 Correct 179 ms 7888 KB Output is correct
11 Correct 199 ms 7680 KB Output is correct
12 Correct 198 ms 7928 KB Output is correct
13 Correct 179 ms 7968 KB Output is correct
14 Execution timed out 2101 ms 7600 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Execution timed out 2101 ms 10700 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4544 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4440 KB Output is correct
10 Correct 2 ms 4552 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4564 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 2 ms 4444 KB Output is correct
15 Correct 2 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 2 ms 4440 KB Output is correct
19 Correct 2 ms 4440 KB Output is correct
20 Correct 1 ms 4444 KB Output is correct
21 Correct 2 ms 4444 KB Output is correct
22 Correct 2 ms 4440 KB Output is correct
23 Correct 2 ms 4444 KB Output is correct
24 Correct 2 ms 4552 KB Output is correct
25 Correct 2 ms 4956 KB Output is correct
26 Correct 2 ms 4444 KB Output is correct
27 Correct 1 ms 4444 KB Output is correct
28 Correct 2 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4440 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4544 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 77 ms 7216 KB Output is correct
11 Correct 179 ms 7888 KB Output is correct
12 Correct 199 ms 7680 KB Output is correct
13 Correct 198 ms 7928 KB Output is correct
14 Correct 179 ms 7968 KB Output is correct
15 Correct 2 ms 4552 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4564 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 2 ms 4444 KB Output is correct
20 Correct 2 ms 4444 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 2 ms 4440 KB Output is correct
24 Correct 2 ms 4440 KB Output is correct
25 Correct 1 ms 4444 KB Output is correct
26 Correct 2 ms 4444 KB Output is correct
27 Correct 2 ms 4440 KB Output is correct
28 Correct 2 ms 4444 KB Output is correct
29 Correct 2 ms 4552 KB Output is correct
30 Correct 2 ms 4956 KB Output is correct
31 Correct 2 ms 4444 KB Output is correct
32 Correct 1 ms 4444 KB Output is correct
33 Correct 2 ms 4444 KB Output is correct
34 Correct 8 ms 5176 KB Output is correct
35 Correct 195 ms 8380 KB Output is correct
36 Correct 197 ms 8432 KB Output is correct
37 Correct 198 ms 8520 KB Output is correct
38 Correct 197 ms 8468 KB Output is correct
39 Correct 206 ms 8412 KB Output is correct
40 Correct 182 ms 8236 KB Output is correct
41 Correct 205 ms 8640 KB Output is correct
42 Correct 226 ms 8508 KB Output is correct
43 Correct 133 ms 8520 KB Output is correct
44 Correct 204 ms 8632 KB Output is correct
45 Correct 188 ms 10900 KB Output is correct
46 Correct 211 ms 8776 KB Output is correct
47 Correct 206 ms 8384 KB Output is correct
48 Correct 185 ms 8760 KB Output is correct
49 Correct 52 ms 10764 KB Output is correct
50 Correct 47 ms 9352 KB Output is correct
51 Correct 141 ms 10068 KB Output is correct
52 Correct 254 ms 11500 KB Output is correct
53 Correct 212 ms 12316 KB Output is correct
54 Correct 266 ms 13032 KB Output is correct
55 Correct 162 ms 8496 KB Output is correct
56 Correct 277 ms 11892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4544 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 77 ms 7216 KB Output is correct
10 Correct 179 ms 7888 KB Output is correct
11 Correct 199 ms 7680 KB Output is correct
12 Correct 198 ms 7928 KB Output is correct
13 Correct 179 ms 7968 KB Output is correct
14 Execution timed out 2101 ms 7600 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4440 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4544 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 77 ms 7216 KB Output is correct
11 Correct 179 ms 7888 KB Output is correct
12 Correct 199 ms 7680 KB Output is correct
13 Correct 198 ms 7928 KB Output is correct
14 Correct 179 ms 7968 KB Output is correct
15 Execution timed out 2101 ms 7600 KB Time limit exceeded
16 Halted 0 ms 0 KB -