# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1118687 |
2024-11-26T02:16:52 Z |
YSH2020 |
Drivers (BOI24_drivers) |
C++17 |
|
1 ms |
340 KB |
#include <bits/stdc++.h>
using namespace std;
int p[200005];
int parent(int n) {
if (p[n] == n) return n;
return p[n] = parent(p[n]);
}
void merge(int x, int y) {
x = parent(x); y = parent(y);
if (x == y) return;
p[x] = y;
}
int main() {
int n, m, u; cin >> n >> m >> u;
vector <pair<int, pair<int, int>>> edges;
for (int i = 0; i < m; i++) {
int x, y, w; cin >> x >> y >> w;
edges.push_back({w, {x, y}});
}
sort(edges.begin(), edges.end());
for (int i = 1; i <= n; i++) p[i] = i;
vector <pair<pair<int, int>, pair<int, int>>> query;
int ans[u];
for (int i = 0; i < u; i++) {
int x, y, dist; cin >> x >> y >> dist;
query.push_back({{dist, i}, {x, y}});
}
sort(query.begin(), query.end());
int idx = 0;
for (int i = 0; i < u; i++) {
while (idx < m and edges[idx].first <= query[i].first.first) {
merge(edges[idx].second.first, edges[idx].second.second);
idx++;
}
if (parent(query[i].second.first) == parent(query[i].second.second)) ans[query[i].first.second] = 1;
else ans[query[i].first.second] = 0;
}
for (int i = 0; i < u; i++) {
if (ans[i] == 0) cout << "TAIP" << '\n';
else cout << "NE" << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |