結果

問題 No.2431 Viral Hotel
ユーザー pockynypockyny
提出日時 2023-08-18 23:13:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,319 bytes
コンパイル時間 740 ms
コンパイル使用メモリ 86,628 KB
実行使用メモリ 22,144 KB
最終ジャッジ日時 2024-05-06 05:48:27
合計ジャッジ時間 6,698 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 41 ms
6,784 KB
testcase_08 AC 40 ms
6,784 KB
testcase_09 AC 3 ms
5,888 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 9 ms
6,272 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 4 ms
5,760 KB
testcase_40 AC 2 ms
6,016 KB
testcase_41 AC 2 ms
5,888 KB
testcase_42 AC 2 ms
5,888 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <set>
#include <vector>

using namespace std;
typedef pair<int,int> pii;
vector<int> G[100010];
int s[100010],c[100010];
bool cure[100010],iru[100010];
int main(){
    int i,n,k,m,p; cin >> n >> k >> m >> p;
    for(i=0;i<m;i++){
        int u,v; cin >> u >> v; u--; v--;
        G[u].push_back(v); G[v].push_back(u);
    }
    for(i=0;i<n;i++){
        cure[i] = false; iru[i] = true;
    }
    set<pair<pii,int>> ms;
    for(i=0;i<n;i++) cin >> s[i];
    for(i=0;i<k;i++){
        int x; cin >> x; x--;
        ms.insert({{p,-1},x});
        ms.insert({{s[x],1},x});
        c[x] = 1;
    }
    while(ms.size()){
        auto x = *ms.begin();
        ms.erase(ms.find(x));
        if(x.first.second==-1){
            cure[x.second] = true;
        }else{
            if(!iru[x.second]) continue;
            for(int u:G[x.second]){
                if(!c[u]){
                    c[u] = 1;
                    ms.insert({{x.first.first + s[u],1},u});
                    ms.insert({{x.first.first + p,-1},u});
                }else{
                    if(!cure[u]) iru[u] = false;
                }
            }
        }
    }
    int ans = 0;
    for(i=0;i<n;i++){
        if(!iru[i]) ans++;
    }
    cout << ans << "\n";
    // for(i=0;i<n;i++) cout << iru[i];
    // cout << endl;
}
0