結果

問題 No.2431 Viral Hotel
ユーザー pockynypockyny
提出日時 2023-08-19 00:21:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 148 ms / 2,000 ms
コード長 1,669 bytes
コンパイル時間 2,146 ms
コンパイル使用メモリ 101,924 KB
実行使用メモリ 12,216 KB
最終ジャッジ日時 2024-05-06 07:15:53
合計ジャッジ時間 5,876 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
10,524 KB
testcase_01 AC 95 ms
9,968 KB
testcase_02 AC 104 ms
10,240 KB
testcase_03 AC 114 ms
11,008 KB
testcase_04 AC 123 ms
11,188 KB
testcase_05 AC 134 ms
11,776 KB
testcase_06 AC 42 ms
6,912 KB
testcase_07 AC 42 ms
6,784 KB
testcase_08 AC 42 ms
6,656 KB
testcase_09 AC 2 ms
6,016 KB
testcase_10 AC 3 ms
5,760 KB
testcase_11 AC 3 ms
6,016 KB
testcase_12 AC 148 ms
12,216 KB
testcase_13 AC 126 ms
10,496 KB
testcase_14 AC 58 ms
8,576 KB
testcase_15 AC 26 ms
6,784 KB
testcase_16 AC 69 ms
9,380 KB
testcase_17 AC 50 ms
8,040 KB
testcase_18 AC 112 ms
10,836 KB
testcase_19 AC 72 ms
9,232 KB
testcase_20 AC 40 ms
7,744 KB
testcase_21 AC 32 ms
7,424 KB
testcase_22 AC 76 ms
8,828 KB
testcase_23 AC 83 ms
9,088 KB
testcase_24 AC 51 ms
8,448 KB
testcase_25 AC 106 ms
10,112 KB
testcase_26 AC 69 ms
8,832 KB
testcase_27 AC 74 ms
8,960 KB
testcase_28 AC 59 ms
8,448 KB
testcase_29 AC 58 ms
8,448 KB
testcase_30 AC 70 ms
8,448 KB
testcase_31 AC 91 ms
9,656 KB
testcase_32 AC 31 ms
7,296 KB
testcase_33 AC 63 ms
8,192 KB
testcase_34 AC 8 ms
6,144 KB
testcase_35 AC 22 ms
6,784 KB
testcase_36 AC 92 ms
10,372 KB
testcase_37 AC 68 ms
8,860 KB
testcase_38 AC 39 ms
7,680 KB
testcase_39 AC 3 ms
5,888 KB
testcase_40 AC 3 ms
6,016 KB
testcase_41 AC 3 ms
5,888 KB
testcase_42 AC 2 ms
5,888 KB
testcase_43 AC 123 ms
12,020 KB
testcase_44 AC 82 ms
9,692 KB
testcase_45 AC 62 ms
8,516 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

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;
    }
    map<int,vector<pair<int,int>>> ms;
    for(i=0;i<n;i++) cin >> s[i];
    for(i=0;i<k;i++){
        int x; cin >> x; x--;
        ms[p].push_back({-1,x});
        ms[s[x]].push_back({1,x});
        c[x] = 1;
    }
    while(ms.size()){
        auto x = *ms.begin();
        ms.erase(x.first);
        vector<pair<int,int>> v = x.second;
        sort(v.begin(),v.end());
        vector<int> del;
        for(auto pp:v){
            if(pp.first==-1){
                cure[pp.second] = true;
            }else{
                if(!iru[pp.second]) continue;
                for(int u:G[pp.second]){
                    if(!cure[u]){
                        if(!c[u]){
                            c[u] = 1;
                            ms[x.first + p].push_back({-1,u});
                            ms[x.first + s[u]].push_back({1,u});
                        }else{
                            del.push_back(u);
                        }
                    }
                }
            }
        }
        for(int u:del){
            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