結果

問題 No.2431 Viral Hotel
ユーザー 👑 kmjpkmjp
提出日時 2023-08-19 01:16:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 1,517 bytes
コンパイル時間 2,318 ms
コンパイル使用メモリ 209,652 KB
実行使用メモリ 10,596 KB
最終ジャッジ日時 2024-05-06 08:26:00
合計ジャッジ時間 5,743 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
9,776 KB
testcase_01 AC 54 ms
9,224 KB
testcase_02 AC 58 ms
9,652 KB
testcase_03 AC 68 ms
10,436 KB
testcase_04 AC 71 ms
10,436 KB
testcase_05 AC 80 ms
10,596 KB
testcase_06 AC 18 ms
6,952 KB
testcase_07 AC 19 ms
7,092 KB
testcase_08 AC 19 ms
6,980 KB
testcase_09 AC 4 ms
6,980 KB
testcase_10 AC 3 ms
6,940 KB
testcase_11 AC 3 ms
6,940 KB
testcase_12 AC 83 ms
10,408 KB
testcase_13 AC 71 ms
9,892 KB
testcase_14 AC 33 ms
8,128 KB
testcase_15 AC 15 ms
6,948 KB
testcase_16 AC 39 ms
8,232 KB
testcase_17 AC 28 ms
7,672 KB
testcase_18 AC 68 ms
9,544 KB
testcase_19 AC 43 ms
8,472 KB
testcase_20 AC 22 ms
8,136 KB
testcase_21 AC 17 ms
7,748 KB
testcase_22 AC 43 ms
8,612 KB
testcase_23 AC 48 ms
8,672 KB
testcase_24 AC 29 ms
8,192 KB
testcase_25 AC 62 ms
9,468 KB
testcase_26 AC 37 ms
8,900 KB
testcase_27 AC 43 ms
8,704 KB
testcase_28 AC 34 ms
8,516 KB
testcase_29 AC 35 ms
8,512 KB
testcase_30 AC 40 ms
8,648 KB
testcase_31 AC 54 ms
9,204 KB
testcase_32 AC 17 ms
7,232 KB
testcase_33 AC 34 ms
8,392 KB
testcase_34 AC 5 ms
6,940 KB
testcase_35 AC 14 ms
6,940 KB
testcase_36 AC 60 ms
9,172 KB
testcase_37 AC 39 ms
8,520 KB
testcase_38 AC 22 ms
7,680 KB
testcase_39 AC 3 ms
6,940 KB
testcase_40 AC 3 ms
6,944 KB
testcase_41 AC 4 ms
6,940 KB
testcase_42 AC 4 ms
6,940 KB
testcase_43 AC 70 ms
10,488 KB
testcase_44 AC 46 ms
8,856 KB
testcase_45 AC 34 ms
8,300 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

int N,K,M,P;
vector<int> E[101010];
int S[101010];
int D[101010];
int fix[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K>>M>>P;
	FOR(i,M) {
		cin>>x>>y;
		E[x-1].push_back(y-1);
		E[y-1].push_back(x-1);
	}
	FOR(i,N) cin>>S[i];
	FOR(i,N) D[i]=1<<30;
	priority_queue<pair<int,int>> Q;
	FOR(i,K) {
		cin>>x;
		x--;
		D[x]=0;
		Q.push({-S[x],x});
	}
	MINUS(fix);
	int ret=0;
	while(Q.size()) {
		int cd=-Q.top().first;
		int cur=Q.top().second;
		Q.pop();
		if(fix[cur]!=-1&&fix[cur]<cd) continue;
		FORR(e,E[cur]) {
			if(D[e]==1<<30) {
				D[e]=cd;
				Q.push({-(cd+S[e]),e});
			}
			else if(cd<D[e]+P&&fix[e]==-1) {
				ret++;
				D[e]=-1;
				fix[e]=cd;
			}
		}
		
	}
	cout<<ret<<endl;
	
		
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0