結果

問題 No.2431 Viral Hotel
ユーザー 0214sh70214sh7
提出日時 2023-08-14 20:52:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,323 bytes
コンパイル時間 2,481 ms
コンパイル使用メモリ 213,664 KB
実行使用メモリ 17,296 KB
最終ジャッジ日時 2024-05-02 18:40:22
合計ジャッジ時間 7,503 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 41 ms
5,376 KB
testcase_07 AC 43 ms
5,376 KB
testcase_08 AC 42 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 196 ms
17,296 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 30 ms
5,588 KB
testcase_16 AC 92 ms
13,720 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 36 ms
6,556 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 WA -
testcase_39 AC 2 ms
5,376 KB
testcase_40 AC 2 ms
5,376 KB
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

//WA解法: 回復後にうつさない
#include <bits/stdc++.h>
using namespace std;
const long long INF = (1ll<<61)-1;

int main(void){
    //cin.tie(nullptr);
    //ios::sync_with_stdio(false);
    
    long long N,K,M,P;
    cin >> N >> K >> M >> P;
    vector<vector<long long>> G(N);
    for(int i=0;i<M;i++){
        long long u,v;
        cin >> u >> v;
        u--;v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    vector<long long> S(N),X(K);
    for(int i=0;i<N;i++){
        cin >> S[i];
    }
    for(int i=0;i<K;i++){
        cin >> X[i];
        X[i]--;
    }

    // {イベントが起こる日,イベントの種類,起こる頂点}
    priority_queue<
        array<long long,3>,
        vector<array<long long,3>>,
        greater<array<long long,3>>
    > que;

    long long Ans = 0;

    //回復したか
    vector<bool> recovered(N,false);
    //検疫が入ったか
    vector<bool> quarantined(N,false);

    //いま感染しているか
    vector<int> infected(N,false);

    //0: 回復 1: 隣に感染 2:検疫 
    for(int i=0;i<K;i++){
        infected[X[i]] = true;
        que.push({P,0,X[i]});
        que.push({S[X[i]],1,X[i]});
    }

    while(!que.empty()){
        array<long long,3> q = que.top();
        que.pop();
        
        //検疫が入った場合その後一切のアクションを起こさない
        if(quarantined[q[2]])continue;

        //回復した場合もその後一切のアクションを起こさない
        if(recovered[q[2]])continue;

        if(q[1] == 0){
            //回復
            infected[q[2]] = false;
            recovered[q[2]] = true;
        }else if(q[1] == 1){
            //隣にうつす
            for(long long e:G[q[2]]){
                if(recovered[e] || quarantined[e])continue;
                //すでにかかっていた場合検疫送り
                if(infected[e]){
                    que.push({q[0],2,e});
                }else{
                    infected[e] = true;
                    que.push({q[0]+P,0,e});
                    que.push({q[0]+S[e],1,e});
                }
            }
        }else{
            //検疫
            Ans++;
            infected[q[2]] = false;
            quarantined[q[2]] = true;
        }
    }

    cout << Ans << endl;

    return 0;
}
0