結果

問題 No.2431 Viral Hotel
ユーザー noya2noya2
提出日時 2023-08-14 21:51:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,445 bytes
コンパイル時間 2,147 ms
コンパイル使用メモリ 211,468 KB
実行使用メモリ 14,208 KB
最終ジャッジ日時 2024-05-02 18:41:11
合計ジャッジ時間 7,680 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 40 ms
5,376 KB
testcase_07 AC 38 ms
5,376 KB
testcase_08 AC 39 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 201 ms
14,204 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 88 ms
11,280 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 38 ms
5,832 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 8 ms
5,376 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 41 ms
6,784 KB
testcase_39 AC 2 ms
5,376 KB
testcase_40 AC 1 ms
5,376 KB
testcase_41 AC 1 ms
5,376 KB
testcase_42 AC 2 ms
5,376 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pli = pair<ll,int>;

int main(){
    int n, k, m, p; cin >> n >> k >> m >> p;
    vector<vector<int>> g(n);
    while (m--){
        int u, v; cin >> u >> v; u--, v--;
        g[u].emplace_back(v);
        g[v].emplace_back(u);
    }
    vector<ll> s(n);
    for (int i = 0; i < n; i++) cin >> s[i];
    /*
        0 : none
        1 : infected
        2 : cured
        3 : infected again
    */
    vector<ll> status(n,0);
    priority_queue<pli,vector<pli>,greater<pli>> pque;
    auto id = [&](ll t, int type){
        return t * 3 + type;
    };
    while (k--){
        int x; cin >> x; x--;
        pque.push(pli(id(0,2),x));
    }
    int ans = 0;
    while (!pque.empty()){
        auto [tt, v] = pque.top(); pque.pop();
        ll t = tt / 3;
        int type = tt % 3;
        if (type == 0){
            status[v] = 2;
        }
        if (type == 1){
            if (status[v] == 3) continue;
            for (int u : g[v]){
                pque.push(pli(id(t,2),u));
            }
        }
        if (type == 2){
            if (status[v] >= 2) continue;
            if (status[v] == 0){
                status[v] = 1;
                pque.push(pli(id(t+s[v],1),v));
                pque.push(pli(id(t+p,0),v));
            }
            else {
                ans++;
                status[v] = 3;
            }
        }
    }
    cout << ans << endl;
}
0