結果
| 問題 | 
                            No.748 yuki国のお財布事情
                             | 
                    
| コンテスト | |
| ユーザー | 
                             🍮かんプリン
                         | 
                    
| 提出日時 | 2019-09-14 15:25:27 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,627 bytes | 
| コンパイル時間 | 1,754 ms | 
| コンパイル使用メモリ | 181,484 KB | 
| 実行使用メモリ | 13,640 KB | 
| 最終ジャッジ日時 | 2024-07-06 03:26:28 | 
| 合計ジャッジ時間 | 4,438 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 15 WA * 11 | 
ソースコード
#include "bits/stdc++.h"
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = MOD - 1;
const ll LLINF = 4e18;
// 最小全域木 O(ElogV)?
struct Edge {
    ll cost, to;
    bool operator>(const Edge e)const {
        return this->cost > e.cost;
    }
};
int Prim(const vector<vector<Edge>> &G) {
    ll res = 0;
    vector<bool> used(G.size(), false);
    priority_queue<Edge, vector<Edge>, greater<Edge>> pq;
    for (Edge e : G[0]) {
        pq.push(e);
    }
    used[0] = true;
    while (!pq.empty()) {
        Edge e = pq.top(); pq.pop();
        if (used[e.to]) continue;
        used[e.to] = true;
        res += e.cost;
        for (Edge u : G[e.to]) {
            if (used[u.to]) continue;
            pq.push(u);
        }
    }
    return res;
}
int main() {
    int n, m, k; cin >> n >> m >> k;
    vector<tuple<ll,ll,ll>> E(m);
    vector<vector<Edge>> G(n);
    ll sum = 0;
    REP(i, m) {
        ll a, b, c; cin >> a >> b >> c;
        a--; b--;
        E[i] = {a,b,c};
    }
    REP(i, k) {
        ll e; cin >> e;
        e--;
        E[e] = {get<0>(E[e]),get<1>(E[e]),0};
    }
    REP(i, m) {
        G[get<0>(E[i])].push_back({get<2>(E[i]),get<1>(E[i])});
        G[get<1>(E[i])].push_back({get<2>(E[i]),get<0>(E[i])});
        sum += get<2>(E[i]);
    }
    cout << sum - Prim(G) << endl;
    getchar(); getchar();
}
            
            
            
        
            
🍮かんプリン