結果

問題 No.2431 Viral Hotel
ユーザー 👑 獅子座じゃない人獅子座じゃない人
提出日時 2023-08-18 23:37:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,277 bytes
コンパイル時間 2,359 ms
コンパイル使用メモリ 215,736 KB
実行使用メモリ 14,216 KB
最終ジャッジ日時 2024-05-06 06:25:07
合計ジャッジ時間 7,720 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(void) {
    int n,k,m,p;
    cin >> n >> k >> m >> p;
    vector<int> u(m);
    vector<int> v(m);
    vector<vector<int>> g(n);
    for(int i=0;i<m;++i){
        cin >> u[i] >> v[i];
        --u[i];
        --v[i];
        g[u[i]].emplace_back(v[i]);
        g[v[i]].emplace_back(u[i]);
    }
    vector<int> s(n);
    for(int i=0;i<n;++i){
        cin >> s[i];
    }
    vector<int> x(k);
    vector<int> day(n,INT_MAX-1);
    int ans=0;
    priority_queue<tuple<int,int,int>,vector<tuple<int,int,int>>,greater<tuple<int,int,int>>> q;
    for(int i=0;i<k;++i){
        cin >> x[i];
        --x[i];
        day[x[i]]=0;
        q.emplace(p,0,x[i]);
        q.emplace(s[x[i]],1,x[i]);
    }
    while(!q.empty()){
        auto [d,t,h]=q.top();
        q.pop();
        if(t){
            for(auto next: g[h]){
                if(day[next]<INT_MAX-1){
                    day[next]=INT_MAX;
                    ++ans;
                } else if(day[next]<INT_MAX){
                    day[next]=d;
                    q.emplace(d+s[next],1,next);
                    q.emplace(d+p,0,next);
                }
            }
        } else {
            day[h]=INT_MAX;
        }
    }
    cout << ans << endl;
    return 0;
}
0