結果

問題 No.2431 Viral Hotel
ユーザー 沙耶花沙耶花
提出日時 2023-08-18 22:44:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 175 ms / 2,000 ms
コード長 1,304 bytes
コンパイル時間 4,061 ms
コンパイル使用メモリ 264,704 KB
実行使用メモリ 11,376 KB
最終ジャッジ日時 2024-05-06 05:07:39
合計ジャッジ時間 9,117 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
9,360 KB
testcase_01 AC 118 ms
8,992 KB
testcase_02 AC 119 ms
9,292 KB
testcase_03 AC 138 ms
10,368 KB
testcase_04 AC 141 ms
10,924 KB
testcase_05 AC 161 ms
10,796 KB
testcase_06 AC 40 ms
5,376 KB
testcase_07 AC 40 ms
5,376 KB
testcase_08 AC 42 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 175 ms
11,376 KB
testcase_13 AC 133 ms
9,728 KB
testcase_14 AC 68 ms
7,040 KB
testcase_15 AC 27 ms
5,376 KB
testcase_16 AC 81 ms
8,896 KB
testcase_17 AC 56 ms
6,016 KB
testcase_18 AC 133 ms
10,152 KB
testcase_19 AC 81 ms
8,344 KB
testcase_20 AC 39 ms
6,272 KB
testcase_21 AC 33 ms
5,376 KB
testcase_22 AC 87 ms
7,724 KB
testcase_23 AC 91 ms
7,680 KB
testcase_24 AC 52 ms
6,784 KB
testcase_25 AC 115 ms
9,088 KB
testcase_26 AC 71 ms
7,936 KB
testcase_27 AC 81 ms
7,552 KB
testcase_28 AC 65 ms
6,784 KB
testcase_29 AC 67 ms
6,528 KB
testcase_30 AC 80 ms
6,784 KB
testcase_31 AC 104 ms
9,144 KB
testcase_32 AC 32 ms
5,376 KB
testcase_33 AC 64 ms
6,272 KB
testcase_34 AC 7 ms
5,376 KB
testcase_35 AC 21 ms
5,376 KB
testcase_36 AC 112 ms
9,312 KB
testcase_37 AC 76 ms
7,496 KB
testcase_38 AC 37 ms
6,272 KB
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 AC 151 ms
11,300 KB
testcase_44 AC 96 ms
8,392 KB
testcase_45 AC 71 ms
7,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001


int main(){
	
	int N,K,M,P;
	cin>>N>>K>>M>>P;
	
	vector<vector<int>> E(N);
	rep(i,M){
		int u,v;
		cin>>u>>v;
		u--,v--;
		E[u].push_back(v);
		E[v].push_back(u);
	}
	
	vector<int> s(N);
	rep(i,N)cin>>s[i];
	using Pd = pair<int,int>;
	priority_queue<Pd,vector<Pd>,greater<Pd>> Q;
	
	vector<int> mode(N);
	rep(i,K){
		int x;
		cin>>x;
		x--;
		mode[x]++;
		Q.emplace(P*3,x);
		Q.emplace(s[x]*3+1,x);
	}
	
	while(Q.size()>0){
		int day = Q.top().first;
		int x = Q.top().second;
		Q.pop();
		//cout<<day<<' '<<x<<endl;
		if(mode[x]==-2)continue;
		if(day%3==0){
			mode[x] = -1;
		}
		if(day%3==1){
			rep(i,E[x].size()){
				int to = E[x][i];
				//cout<<to<<endl;
				if(mode[to]>=0){
					if(mode[to]==1){
						mode[to]++;
						Q.emplace(day+1,to);
					}
					if(mode[to]==0){
						mode[to]++;
						Q.emplace(((day/3)+P)*3,to);
						Q.emplace(((day/3)+s[to])*3+1,to);
					}
					
				}
			}
		}
		if(day%3==2){
			mode[x] = -2;
		}
	}
	int ans = 0;
	rep(i,N){
		//cout<<mode[i]<<endl;
		if(mode[i]==-2)ans++;
	}
	cout<<ans<<endl;
	
	return 0;
}
0