結果

問題 No.2431 Viral Hotel
ユーザー fumofumofunifumofumofuni
提出日時 2023-08-18 22:40:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 170 ms / 2,000 ms
コード長 2,514 bytes
コンパイル時間 2,923 ms
コンパイル使用メモリ 212,444 KB
実行使用メモリ 17,552 KB
最終ジャッジ日時 2023-08-18 22:40:16
合計ジャッジ時間 8,258 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
12,436 KB
testcase_01 AC 128 ms
12,564 KB
testcase_02 AC 119 ms
12,012 KB
testcase_03 AC 138 ms
12,368 KB
testcase_04 AC 145 ms
14,636 KB
testcase_05 AC 159 ms
13,920 KB
testcase_06 AC 37 ms
5,500 KB
testcase_07 AC 36 ms
5,264 KB
testcase_08 AC 41 ms
5,460 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 1 ms
4,384 KB
testcase_12 AC 170 ms
17,552 KB
testcase_13 AC 167 ms
12,144 KB
testcase_14 AC 71 ms
8,592 KB
testcase_15 AC 29 ms
5,364 KB
testcase_16 AC 81 ms
13,808 KB
testcase_17 AC 53 ms
7,372 KB
testcase_18 AC 127 ms
16,164 KB
testcase_19 AC 78 ms
10,588 KB
testcase_20 AC 39 ms
7,060 KB
testcase_21 AC 30 ms
6,372 KB
testcase_22 AC 83 ms
10,264 KB
testcase_23 AC 87 ms
9,580 KB
testcase_24 AC 51 ms
7,928 KB
testcase_25 AC 112 ms
11,132 KB
testcase_26 AC 66 ms
9,640 KB
testcase_27 AC 100 ms
9,232 KB
testcase_28 AC 63 ms
8,188 KB
testcase_29 AC 62 ms
8,336 KB
testcase_30 AC 73 ms
8,776 KB
testcase_31 AC 98 ms
11,900 KB
testcase_32 AC 30 ms
5,556 KB
testcase_33 AC 63 ms
7,988 KB
testcase_34 AC 6 ms
4,384 KB
testcase_35 AC 21 ms
5,000 KB
testcase_36 AC 110 ms
11,912 KB
testcase_37 AC 76 ms
9,860 KB
testcase_38 AC 36 ms
6,904 KB
testcase_39 AC 2 ms
4,384 KB
testcase_40 AC 1 ms
4,384 KB
testcase_41 AC 1 ms
4,380 KB
testcase_42 AC 1 ms
4,380 KB
testcase_43 AC 148 ms
16,252 KB
testcase_44 AC 112 ms
10,588 KB
testcase_45 AC 81 ms
8,292 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