답안 #1111363

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1111363 2024-11-12T07:42:50 Z siewjh Drivers (BOI24_drivers) C++17
100 / 100
112 ms 8272 KB
#include <bits/stdc++.h>
using namespace std;
typedef tuple<int, int, int> i3;
typedef tuple<int, int, int, int> i4;
const int MAXN = 200005;
int par[MAXN], rnk[MAXN];
int root(int x){
	if (par[x] == -1) return x;
	else return par[x] = root(par[x]);
}
void join(int a, int b){
	int ra = root(a), rb = root(b);
	if (ra == rb) return;
	if (rnk[ra] > rnk[rb]) swap(ra, rb);
	par[ra] = rb;
	if (rnk[ra] == rnk[rb]) rnk[rb]++;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int nodes, edges, queries; cin >> nodes >> edges >> queries;
	memset(par, -1, sizeof(par));
	vector<i3> ev(edges);
	vector<i4> pv(queries);
	for (int i = 0; i < edges; i++){
		int a, b, c; cin >> a >> b >> c;
		ev[i] = {c, a, b};
	}
	sort(ev.begin(), ev.end());
	for (int i = 0; i < queries; i++){
		int a, b, p; cin >> a >> b >> p;
		pv[i] = {p, a, b, i};
	}
	sort(pv.begin(), pv.end());
	vector<bool> ans(queries);
	int eid = 0;
	for (auto [p, a, b, i] : pv){
		for (; eid != edges && get<0>(ev[eid]) <= p; eid++){
			int ea, eb, ec; tie(ec, ea, eb) = ev[eid];
			join(ea, eb);
		}
		ans[i] = (root(a) == root(b));
	}
	for (bool b : ans) cout << (b ? "TAIP" : "NE") << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1104 KB Output is correct
2 Correct 2 ms 1104 KB Output is correct
3 Correct 2 ms 1272 KB Output is correct
4 Correct 1 ms 1104 KB Output is correct
5 Correct 58 ms 5260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1104 KB Output is correct
2 Correct 1 ms 1104 KB Output is correct
3 Correct 2 ms 1104 KB Output is correct
4 Correct 2 ms 1104 KB Output is correct
5 Correct 2 ms 1104 KB Output is correct
6 Correct 2 ms 1104 KB Output is correct
7 Correct 2 ms 1104 KB Output is correct
8 Correct 2 ms 1104 KB Output is correct
9 Correct 2 ms 1104 KB Output is correct
10 Correct 3 ms 1104 KB Output is correct
11 Correct 3 ms 1104 KB Output is correct
12 Correct 3 ms 1360 KB Output is correct
13 Correct 2 ms 1104 KB Output is correct
14 Correct 3 ms 1360 KB Output is correct
15 Correct 1 ms 1104 KB Output is correct
16 Correct 2 ms 1104 KB Output is correct
17 Correct 1 ms 1104 KB Output is correct
18 Correct 2 ms 1104 KB Output is correct
19 Correct 6 ms 1360 KB Output is correct
20 Correct 2 ms 1104 KB Output is correct
21 Correct 2 ms 1104 KB Output is correct
22 Correct 1 ms 1104 KB Output is correct
23 Correct 2 ms 1156 KB Output is correct
24 Correct 5 ms 1360 KB Output is correct
25 Correct 1 ms 1104 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1104 KB Output is correct
2 Correct 2 ms 1104 KB Output is correct
3 Correct 2 ms 1272 KB Output is correct
4 Correct 1 ms 1104 KB Output is correct
5 Correct 58 ms 5260 KB Output is correct
6 Correct 2 ms 1104 KB Output is correct
7 Correct 2 ms 1104 KB Output is correct
8 Correct 2 ms 1104 KB Output is correct
9 Correct 3 ms 1104 KB Output is correct
10 Correct 3 ms 1360 KB Output is correct
11 Correct 3 ms 1360 KB Output is correct
12 Correct 1 ms 1104 KB Output is correct
13 Correct 2 ms 1104 KB Output is correct
14 Correct 1 ms 1104 KB Output is correct
15 Correct 1 ms 1104 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1104 KB Output is correct
2 Correct 2 ms 1104 KB Output is correct
3 Correct 2 ms 1272 KB Output is correct
4 Correct 1 ms 1104 KB Output is correct
5 Correct 58 ms 5260 KB Output is correct
6 Correct 2 ms 1104 KB Output is correct
7 Correct 1 ms 1104 KB Output is correct
8 Correct 2 ms 1104 KB Output is correct
9 Correct 2 ms 1104 KB Output is correct
10 Correct 2 ms 1104 KB Output is correct
11 Correct 2 ms 1104 KB Output is correct
12 Correct 2 ms 1104 KB Output is correct
13 Correct 2 ms 1104 KB Output is correct
14 Correct 2 ms 1104 KB Output is correct
15 Correct 3 ms 1104 KB Output is correct
16 Correct 3 ms 1104 KB Output is correct
17 Correct 3 ms 1360 KB Output is correct
18 Correct 2 ms 1104 KB Output is correct
19 Correct 3 ms 1360 KB Output is correct
20 Correct 1 ms 1104 KB Output is correct
21 Correct 2 ms 1104 KB Output is correct
22 Correct 1 ms 1104 KB Output is correct
23 Correct 2 ms 1104 KB Output is correct
24 Correct 6 ms 1360 KB Output is correct
25 Correct 2 ms 1104 KB Output is correct
26 Correct 2 ms 1104 KB Output is correct
27 Correct 1 ms 1104 KB Output is correct
28 Correct 2 ms 1156 KB Output is correct
29 Correct 5 ms 1360 KB Output is correct
30 Correct 1 ms 1104 KB Output is correct
31 Correct 2 ms 1104 KB Output is correct
32 Correct 2 ms 1104 KB Output is correct
33 Correct 2 ms 1104 KB Output is correct
34 Correct 3 ms 1104 KB Output is correct
35 Correct 3 ms 1360 KB Output is correct
36 Correct 3 ms 1360 KB Output is correct
37 Correct 1 ms 1104 KB Output is correct
38 Correct 2 ms 1104 KB Output is correct
39 Correct 1 ms 1104 KB Output is correct
40 Correct 1 ms 1104 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1104 KB Output is correct
2 Correct 2 ms 1104 KB Output is correct
3 Correct 2 ms 1272 KB Output is correct
4 Correct 1 ms 1104 KB Output is correct
5 Correct 58 ms 5260 KB Output is correct
6 Correct 2 ms 1104 KB Output is correct
7 Correct 1 ms 1104 KB Output is correct
8 Correct 2 ms 1104 KB Output is correct
9 Correct 2 ms 1104 KB Output is correct
10 Correct 2 ms 1104 KB Output is correct
11 Correct 2 ms 1104 KB Output is correct
12 Correct 2 ms 1104 KB Output is correct
13 Correct 2 ms 1104 KB Output is correct
14 Correct 2 ms 1104 KB Output is correct
15 Correct 3 ms 1104 KB Output is correct
16 Correct 3 ms 1104 KB Output is correct
17 Correct 3 ms 1360 KB Output is correct
18 Correct 2 ms 1104 KB Output is correct
19 Correct 3 ms 1360 KB Output is correct
20 Correct 1 ms 1104 KB Output is correct
21 Correct 2 ms 1104 KB Output is correct
22 Correct 1 ms 1104 KB Output is correct
23 Correct 2 ms 1104 KB Output is correct
24 Correct 6 ms 1360 KB Output is correct
25 Correct 2 ms 1104 KB Output is correct
26 Correct 2 ms 1104 KB Output is correct
27 Correct 1 ms 1104 KB Output is correct
28 Correct 2 ms 1156 KB Output is correct
29 Correct 5 ms 1360 KB Output is correct
30 Correct 1 ms 1104 KB Output is correct
31 Correct 2 ms 1104 KB Output is correct
32 Correct 2 ms 1104 KB Output is correct
33 Correct 2 ms 1104 KB Output is correct
34 Correct 3 ms 1104 KB Output is correct
35 Correct 3 ms 1360 KB Output is correct
36 Correct 3 ms 1360 KB Output is correct
37 Correct 1 ms 1104 KB Output is correct
38 Correct 2 ms 1104 KB Output is correct
39 Correct 1 ms 1104 KB Output is correct
40 Correct 1 ms 1104 KB Output is correct
41 Correct 112 ms 8272 KB Output is correct
42 Correct 8 ms 1616 KB Output is correct
43 Correct 8 ms 1860 KB Output is correct
44 Correct 12 ms 1852 KB Output is correct
45 Correct 10 ms 1616 KB Output is correct
46 Correct 8 ms 1616 KB Output is correct
47 Correct 100 ms 6180 KB Output is correct
48 Correct 9 ms 1616 KB Output is correct
49 Correct 75 ms 7496 KB Output is correct