답안 #968693

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
968693 2024-04-23T20:39:04 Z blackslex Cities (BOI16_cities) C++17
0 / 100
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

cities.cpp: In function 'int main()':
cities.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf("%d %d %d", &n, &k, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
cities.cpp:14:27: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     for (auto &e: c) scanf("%d", &e);
      |                      ~~~~~^~~~~~~~~~
cities.cpp:15:35: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     for (auto &[z, x, y]: v) scanf("%d %d %lld", &x, &y, &z);
      |                              ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 82 ms 10184 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 130 ms 10204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 85 ms 10176 KB Output isn't correct
2 Halted 0 ms 0 KB -