結果

問題 No.2431 Viral Hotel
ユーザー momoyuumomoyuu
提出日時 2023-08-18 21:50:23
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,392 bytes
コンパイル時間 3,748 ms
コンパイル使用メモリ 257,232 KB
実行使用メモリ 13,416 KB
最終ジャッジ日時 2024-05-06 03:49:20
合計ジャッジ時間 7,997 ms
ジャッジサーバーID
(参考情報)
judge2 / 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 40 ms
5,376 KB
testcase_08 AC 39 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 7 ms
5,376 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 1 ms
5,376 KB
testcase_40 AC 2 ms
5,376 KB
testcase_41 AC 2 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;

int main(){
    ll n,k,m,p;
    cin>>n>>k>>m>>p;
    vector<vector<int>> g(n);
    for(int i = 0;i<m;i++){
        int u,v;
        cin>>u>>v;
        u--;v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    vector<int> now(n,0);
    vector<int> s(n);
    for(int i = 0;i<n;i++) cin>>s[i];
    using dat = pair<ll,pair<int,int>>;
    priority_queue<dat,vector<dat>,greater<dat>> que;
    for(int i = 0;i<k;i++){
        int x;
        cin>>x;
        x--;
        now[x] = 1;
        que.push(make_pair(s[x],make_pair(1,x)));
        que.push(make_pair(p,make_pair(0,x)));
    }
    int ans = 0;
    while(que.size()){
        auto nown = que.top();
        que.pop();
        ll d = nown.first;
        int t = nown.second.first;
        int ni = nown.second.second;
        if(t==1){
            if(now[ni]==-1) continue;
            for(auto&to:g[ni]){
                if(now[to]==0){
                    now[to] = 1;
                    que.push(make_pair(d+s[to],make_pair(1,to)));
                    que.push(make_pair(d+p,make_pair(0,to)));
                }else if(now[to]==1){
                    now[to] = -1;
                    ans++;
                }
            }
        }else if(t==0){
            if(now[ni]==-1) continue;
            now[ni] = 2;
        }
    }
    cout<<ans<<endl;

}

0