답안 #1102988

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1102988 2024-10-19T10:05:49 Z THXuan Drivers (BOI24_drivers) C++14
10 / 100
668 ms 5780 KB
// subtask 1
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#define INF 1e9
using namespace std;
typedef long long ll;

ll link[200005];
ll sz[200005];

ll find(ll x) {
	while (x != link[x]) x = link[x];
	return x;
}

void unite(ll a, ll b) {
	a = find(a);
	b = find(b);
	if (sz[a] < sz[b]) swap(a, b);
	sz[a] += sz[b];
	link[b] = a;
}

void solve()
{
	int n, m, u; cin >> n >> m >> u;
	for (int i = 1; i <= n; i++) {
		link[i] = i; sz[i] = 1;
	}
	ll t = 0;
	for (int i = 1; i <= m; i++) {
		int a, b; cin >> a >> b >> t;
		unite(a, b);
	}
	while (u--) {
		int a, b; cin >> a >> b; ll p; cin >> p;
		if (find(a) != find(b)) {
			cout << "NE" << "\n";
		}
		else if (p < t) {
			cout << "NE" << "\n";
		}
		else cout << "TAIP" << "\n";
	}
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;// cin>>t;
	while (t--) solve();
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2388 KB Output is correct
2 Correct 2 ms 2388 KB Output is correct
3 Correct 2 ms 2388 KB Output is correct
4 Correct 1 ms 2388 KB Output is correct
5 Correct 668 ms 5780 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2388 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2388 KB Output is correct
2 Correct 2 ms 2388 KB Output is correct
3 Correct 2 ms 2388 KB Output is correct
4 Correct 1 ms 2388 KB Output is correct
5 Correct 668 ms 5780 KB Output is correct
6 Incorrect 1 ms 2388 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2388 KB Output is correct
2 Correct 2 ms 2388 KB Output is correct
3 Correct 2 ms 2388 KB Output is correct
4 Correct 1 ms 2388 KB Output is correct
5 Correct 668 ms 5780 KB Output is correct
6 Incorrect 1 ms 2388 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2388 KB Output is correct
2 Correct 2 ms 2388 KB Output is correct
3 Correct 2 ms 2388 KB Output is correct
4 Correct 1 ms 2388 KB Output is correct
5 Correct 668 ms 5780 KB Output is correct
6 Incorrect 1 ms 2388 KB Output isn't correct
7 Halted 0 ms 0 KB -