#include <bits/stdc++.h>
#define int long long
#define float long double
#define pii pair<int, int>
#define f first
#define s second
#define tiii tuple<int, int, int>
#define ve vector
#define emb emplace_back
#define em emplace
using namespace std;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
const int inf = 1e14;
const int mod = 1e9 + 7;
void io(string name);
int par[200000];
int fp(int x) {
if (par[x] == -1) return x;
return par[x] = fp(par[x]);
}
int32_t main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int n, m, u;
cin >> n >> m >> u;
ve<tiii> edges;
while (m--) {
int a, b, c;
cin >> a >> b >> c;
a--, b--;
edges.emb(c, a, b);
}
ve<tuple<int, int, int, int>> q;
for (int i = 0; i < u; i++) {
int a, b, c;
cin >> a >> b >> c;
a--, b--;
q.emb(c, a, b, i);
}
ve<pii> ans;
sort(q.begin(), q.end());
sort(edges.begin(), edges.end());
memset(par, -1, sizeof(par));
int pt = 0;
for (auto &[x, y, z, idx] : q) {
while (x >= get<0>(edges[pt]) && pt < edges.size()) {
auto [w, xx, yy] = edges[pt];
int px = fp(xx), py = fp(yy);
if (px != py) par[px] = py;
pt++;
}
if (fp(y) == fp(z)) ans.emb(idx, 1);
else ans.emb(idx, 0);
}
sort(ans.begin(), ans.end());
for (auto &[x, y] : ans) cout << (y ? "TAIP" : "NE") << '\n';
return 0;
}
void io(string name) {
freopen((name + ".in").c_str(), "r", stdin);
freopen((name + ".out").c_str(), "w", stdout);
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'void io(std::string)':
Main.cpp:68:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
68 | freopen((name + ".in").c_str(), "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:69:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
69 | freopen((name + ".out").c_str(), "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | 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... |