結果

問題 No.2431 Viral Hotel
ユーザー fumofumofunifumofumofuni
提出日時 2023-08-18 22:40:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 174 ms / 2,000 ms
コード長 2,514 bytes
コンパイル時間 2,307 ms
コンパイル使用メモリ 214,468 KB
実行使用メモリ 16,884 KB
最終ジャッジ日時 2024-05-06 05:01:03
合計ジャッジ時間 7,711 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 139 ms
12,652 KB
testcase_01 AC 121 ms
11,836 KB
testcase_02 AC 122 ms
12,344 KB
testcase_03 AC 135 ms
12,588 KB
testcase_04 AC 145 ms
13,996 KB
testcase_05 AC 155 ms
14,384 KB
testcase_06 AC 38 ms
5,376 KB
testcase_07 AC 40 ms
5,376 KB
testcase_08 AC 40 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 174 ms
16,884 KB
testcase_13 AC 135 ms
12,264 KB
testcase_14 AC 65 ms
8,768 KB
testcase_15 AC 27 ms
5,504 KB
testcase_16 AC 83 ms
13,600 KB
testcase_17 AC 57 ms
7,684 KB
testcase_18 AC 137 ms
15,376 KB
testcase_19 AC 90 ms
11,204 KB
testcase_20 AC 39 ms
7,168 KB
testcase_21 AC 34 ms
6,480 KB
testcase_22 AC 87 ms
10,620 KB
testcase_23 AC 92 ms
9,840 KB
testcase_24 AC 53 ms
7,932 KB
testcase_25 AC 126 ms
11,392 KB
testcase_26 AC 74 ms
9,748 KB
testcase_27 AC 83 ms
9,464 KB
testcase_28 AC 67 ms
8,416 KB
testcase_29 AC 67 ms
8,444 KB
testcase_30 AC 90 ms
8,884 KB
testcase_31 AC 102 ms
12,112 KB
testcase_32 AC 33 ms
5,632 KB
testcase_33 AC 65 ms
8,168 KB
testcase_34 AC 7 ms
5,376 KB
testcase_35 AC 23 ms
5,376 KB
testcase_36 AC 121 ms
12,108 KB
testcase_37 AC 87 ms
10,060 KB
testcase_38 AC 41 ms
6,912 KB
testcase_39 AC 2 ms
5,376 KB
testcase_40 AC 1 ms
5,376 KB
testcase_41 AC 1 ms
5,376 KB
testcase_42 AC 1 ms
5,376 KB
testcase_43 AC 159 ms
16,012 KB
testcase_44 AC 96 ms
10,928 KB
testcase_45 AC 70 ms
8,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=(n)-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={0,1,-1,0,1,1,-1,-1,0};
const ll dx[9]={1,0,0,-1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    ll n,k,m,P;cin >> n >> k >> m >> P;
    vvl g(n);
    rep(i,m){
        ll a,b;cin >> a >> b;a--;b--;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    vl s(n);rep(i,n)cin >> s[i];
    vl state(n);//0なら何も持ってない、1なら感染、2なら免疫、3なら検疫
    priority_queue<tuple<ll,ll,ll>,vector<tuple<ll,ll,ll>>,greater<tuple<ll,ll,ll>>> event;
    //時刻、イベント=0なら、免疫獲得、1なら感染、2なら検疫、idx
    rep(i,k){
        ll a;cin >> a;a--;
        state[a]=1;
        event.push({P,0,a});
        event.push({s[a],1,a});
    }
   // ll time=-1;
    while(event.size()){
        auto [t,ev,id]=event.top();event.pop();
        /*if(time!=t){
            for(auto p:state)cout << p <<" ";cout << endl;
            time=t;
        }*/
        if(ev==0){
            if(state[id]!=3)state[id]=2;
        }
        else if(ev==1){
            if(state[id]==3)continue;
            for(auto p:g[id]){
                if(state[p]==0){
                    state[p]=1;
                    event.push({t+P,0,p});
                    event.push({t+s[p],1,p});
                }
                else if(state[p]==1){
                    event.push({t,2,p});
                }
            }
        }
        else {
            state[id]=3;
        }
        
    }
    ll ans=0;
    rep(i,n)if(state[i]==3)ans++;
    cout << ans << endl;
}



0