답안 #1111380

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1111380 2024-11-12T07:56:13 Z gohchingjayk Drivers (BOI24_drivers) C++17
10 / 100
35 ms 1864 KB
#include <bits/stdc++.h>

using namespace std;
using i64 = int64_t;

struct Component {
	int parent;
};

Component components[200001];

int findparent(int src) {
	int &pa = components[src].parent;
	return pa = (pa == src ? pa : findparent(pa));
}

int main() {
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(false);

	int cities, roads, queries;
	cin >> cities >> roads >> queries;

	int t = -1;

	for (int i = 0; i < 200001; ++i) {
		components[i].parent = i;
	}

	for (int i = 0; i < roads; ++i) {
		int a, b, p;
		cin >> a >> b >> p;
		t = p;

		int a_pa = findparent(a);
		int b_pa = findparent(b);
		components[a_pa].parent = b_pa;
	}

	for (int i = 0; i < queries; ++i) {
		int a, b, p;
		cin >> a >> b >> p;
		if (findparent(a) == findparent(b) && p >= t) cout << "TAIP";
		else cout << "NE";
		cout << "\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 1104 KB Output is correct
4 Correct 1 ms 1104 KB Output is correct
5 Correct 35 ms 1864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 1104 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1104 KB Output is correct
2 Correct 2 ms 1104 KB Output is correct
3 Correct 2 ms 1104 KB Output is correct
4 Correct 1 ms 1104 KB Output is correct
5 Correct 35 ms 1864 KB Output is correct
6 Incorrect 1 ms 1104 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1104 KB Output is correct
2 Correct 2 ms 1104 KB Output is correct
3 Correct 2 ms 1104 KB Output is correct
4 Correct 1 ms 1104 KB Output is correct
5 Correct 35 ms 1864 KB Output is correct
6 Incorrect 2 ms 1104 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1104 KB Output is correct
2 Correct 2 ms 1104 KB Output is correct
3 Correct 2 ms 1104 KB Output is correct
4 Correct 1 ms 1104 KB Output is correct
5 Correct 35 ms 1864 KB Output is correct
6 Incorrect 2 ms 1104 KB Output isn't correct
7 Halted 0 ms 0 KB -