結果

問題 No.2431 Viral Hotel
ユーザー bortikbortik
提出日時 2023-08-11 19:50:55
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,315 bytes
コンパイル時間 2,380 ms
コンパイル使用メモリ 211,700 KB
実行使用メモリ 10,476 KB
最終ジャッジ日時 2024-05-02 18:38:53
合計ジャッジ時間 6,411 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

//Solution to Viral Hotel problem by writer: BortiK

#include<bits/stdc++.h>

using namespace std;

int main(){
    int N, K, M, P; 
    cin >> N >> K >> M >> P;
    vector<vector<int>> adj(N);
    for(int i = 0; i < M; i++){
        int u,v; cin >> u >> v;
        u--;v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    vector<int> s(N);
    for(int i = 0; i < N; i++){
        cin >> s[i];
    }

    priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> todo;
    vector<int> infected(N, -1);
    for(int i = 0; i < K; i++){
        int x; cin >> x;
        x--;
        todo.push(make_pair(s[x],x));
        infected[x] = 0;
    }

    vector<bool> quar(N, false);
    int answer = 0;
    
    while(!todo.empty()){
        pair<int,int> x = todo.top();
        todo.pop();
        if(quar[x.second]) continue;
        for(int u: adj[x.second]){
            if(infected[u] == -1){
                infected[u] = x.first;
                todo.push(make_pair(x.first+s[u], u));
            } else {
                if(infected[u]+P > x.first){
                    if(!quar[u]){
                        answer++;
                        quar[u] = true;                        
                    }
                }
            }
        }
    }

    cout << answer;
}
0