# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
968693 | 2024-04-23T20:39:04 Z | blackslex | Cities (BOI16_cities) | C++17 | 130 ms | 10204 KB |
#include<bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using tp = tuple<ll, int, int>; int n, m, k; int main() { scanf("%d %d %d", &n, &k, &m); vector<int> c(k); vector<tp> v(m), v2; for (auto &e: c) scanf("%d", &e); for (auto &[z, x, y]: v) scanf("%d %d %lld", &x, &y, &z); sort(v.begin(), v.end()); vector<int> par(n + 5); iota(par.begin(), par.end(), 0); function<int(int)> fset = [&] (int a) {return (par[a] == a ? a : par[a] = fset(par[a]));}; ll ans = 0; for (auto &[z, x, y]: v) { if (fset(x) != fset(y)) par[fset(x)] = fset(y), v2.emplace_back(z, x, y), ans += z; bool ck = 1; for (auto &e: c) { for (auto &E: c) ck &= (fset(e) == fset(E)); } if (ck) break; } printf("%lld", ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 82 ms | 10184 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 130 ms | 10204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 85 ms | 10176 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |