제출 #1102999

#제출 시각아이디문제언어결과실행 시간메모리
1102999THXuanDrivers (BOI24_drivers)C++14
55 / 100
2057 ms19024 KiB
#include <iostream> #include <vector> #include <algorithm> #include <array> #include <queue> #include <set> #include <map> #define INF 1e9 using namespace std; typedef long long ll; vector<array<ll, 4>>q(200005); 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; } vector<pair<ll, pair<int, int>>>edges(m); vector<string>ans(u); for (int i = 0; i < m; i++) { cin >> edges[i].second.first >> edges[i].second.second >> edges[i].first; } for (int i = 0; i < u; i++) { cin >> q[i][1] >> q[i][2] >> q[i][0]; q[i][3] = i; } sort(edges.begin(), edges.end()); sort(q.begin(), q.begin() + u); int j = 0; for (int i = 0; i < u; i++) { while (j < m && edges[j].first <= q[i][0]) { unite(edges[j].second.first, edges[j].second.second); ++j; } if (find(q[i][1]) == find(q[i][2])) { ans[q[i][3]] = "TAIP"; } else ans[q[i][3]] = "NE"; } for (int i = 0; i < u; i++) { cout << ans[i] << "\n"; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t = 1;// cin>>t; while (t--) solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...