# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
968814 | 2024-04-24T06:35:41 Z | blackslex | Cities (BOI16_cities) | C++17 | 116 ms | 3552 KB |
#include<bits/stdc++.h> using namespace std; using ll = long long; 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); for (auto &e: c) scanf("%d", &e), e--; for (auto &[z, x, y]: v) scanf("%d %d %lld", &x, &y, &z), x--, y--; sort(v.begin(), v.end()); ll ans = 1e18; auto get = [&] (int msk) { for (auto &e: c) if (!(msk & (1 << e))) return; vector<int> par(n); iota(par.begin(), par.end(), 0); function<int(int)> fset = [&] (int a) {return (par[a] == a ? a : par[a] = fset(par[a]));}; ll cur = 0; for (auto &[z, x, y]: v) { if (!(msk & (1 << x)) || !(msk & (1 << y))) continue; if (fset(x) != fset(y)) par[fset(x)] = fset(y), cur += z; } for (auto &e: c) for (auto &E: c) if (fset(e) != fset(E)) return; ans = min(ans, cur); }; for (int i = 0; i < (1 << n); i++) get(i); printf("%lld", ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 116 ms | 404 KB | Output is correct |
3 | Correct | 74 ms | 344 KB | Output is correct |
4 | Correct | 56 ms | 408 KB | Output is correct |
5 | Correct | 27 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 62 ms | 3420 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 344 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 63 ms | 3420 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 72 ms | 3552 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |