#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define fi first
#define se second
using namespace std;
vector<int> adj[1005];
ll par[500005], sz[500005];
ll find(ll a) {
if (par[a] == a) return a;
return par[a] = find(par[a]);
}
void merge(ll a, ll b) {
a = find(a); b = find(b);
if (a == b) return;
if (sz[a] < sz[b]) swap(a, b);
par[b] = a; sz[a] += sz[b]; sz[b] = 0;
}
int main() {
int n, m, u, t; cin >> n >> m >> u;
for (ll i = 1; i <= n; i++) {
par[i] = i; sz[i] = 1;
}
for (int i = 0; i < m; i++) {
int a, b; cin >> a >> b >> t;
merge(a, b);
}
while (u--) {
int a, b, p; cin >> a >> b >> p;
if (p < t) {cout << "NE\n"; continue;}
a = find(a); b = find(b);
cout << (a == b ? "TAIP" : "NE") << "\n";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |