| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1167907 | kungfulon | Drivers (BOI24_drivers) | C++20 | 1 ms | 324 KiB |
#include <bits/stdc++.h>
using namespace std;
int n,m,u;
struct edge{
int u, v, w;
edge(int u, int v, int w): u(u), v(v), w(w) {}
bool operator<(const edge& other) const {
return w < other.w;
}
};
int dsu[200001];
int find(int x){
return !dsu[x] ? x : dsu[x] = find(dsu[x]);
}
int main(){
if(fopen("inp.txt", "r")){
freopen("inp.txt", "r", stdin);
}
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m >> u;
vector<edge> edges;
for(int i = 0; i < m; i++){
int u, v, w;
cin >> u >> v >> w;
edges.push_back(edge(u, v, w));
}
sort(edges.begin(), edges.end());
int id = 0;
for (int i = 0;i < u;i++) {
int a, b, t;
cin >> a >> b >> t;
edge e(a, b, t);
while(id < m && edges[id].w <= t){
if (find(edges[id].u) != find(edges[id].v)){
dsu[find(edges[id].u)] = find(edges[id].v);
}
id++;
}
if (find(a) == find(b)) {
cout << "TAIP\n";
} else {
cout << "NE\n";
}
}
}Compilation message (stderr)
| # | 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... | ||||
