結果

問題 No.2431 Viral Hotel
ユーザー kotatsugamekotatsugame
提出日時 2023-08-18 21:33:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 71 ms / 2,000 ms
コード長 1,100 bytes
コンパイル時間 855 ms
コンパイル使用メモリ 81,688 KB
実行使用メモリ 11,184 KB
最終ジャッジ日時 2024-05-06 03:27:13
合計ジャッジ時間 3,933 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
9,992 KB
testcase_01 AC 45 ms
9,600 KB
testcase_02 AC 51 ms
10,084 KB
testcase_03 AC 60 ms
10,880 KB
testcase_04 AC 60 ms
10,752 KB
testcase_05 AC 67 ms
11,036 KB
testcase_06 AC 18 ms
7,296 KB
testcase_07 AC 18 ms
7,168 KB
testcase_08 AC 17 ms
7,168 KB
testcase_09 AC 3 ms
6,400 KB
testcase_10 AC 3 ms
6,400 KB
testcase_11 AC 3 ms
6,400 KB
testcase_12 AC 71 ms
10,980 KB
testcase_13 AC 58 ms
10,368 KB
testcase_14 AC 29 ms
8,576 KB
testcase_15 AC 14 ms
7,296 KB
testcase_16 AC 34 ms
8,936 KB
testcase_17 AC 26 ms
8,064 KB
testcase_18 AC 55 ms
10,244 KB
testcase_19 AC 35 ms
9,004 KB
testcase_20 AC 19 ms
7,936 KB
testcase_21 AC 16 ms
7,528 KB
testcase_22 AC 37 ms
8,852 KB
testcase_23 AC 38 ms
9,088 KB
testcase_24 AC 24 ms
8,576 KB
testcase_25 AC 52 ms
9,984 KB
testcase_26 AC 32 ms
9,088 KB
testcase_27 AC 35 ms
8,960 KB
testcase_28 AC 28 ms
8,448 KB
testcase_29 AC 31 ms
8,464 KB
testcase_30 AC 35 ms
8,704 KB
testcase_31 AC 42 ms
9,728 KB
testcase_32 AC 16 ms
7,424 KB
testcase_33 AC 28 ms
8,184 KB
testcase_34 AC 5 ms
6,912 KB
testcase_35 AC 11 ms
7,212 KB
testcase_36 AC 46 ms
9,564 KB
testcase_37 AC 34 ms
8,832 KB
testcase_38 AC 18 ms
8,004 KB
testcase_39 AC 3 ms
6,528 KB
testcase_40 AC 3 ms
6,528 KB
testcase_41 AC 2 ms
6,400 KB
testcase_42 AC 2 ms
6,400 KB
testcase_43 AC 63 ms
11,184 KB
testcase_44 AC 42 ms
9,216 KB
testcase_45 AC 31 ms
8,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cassert>
//#include<atcoder/modint>
using namespace std;
//using mint=atcoder::modint998244353;
int N,K,M,P;
vector<int>G[1<<17];
int S[1<<17];
int inf[1<<17];
bool ban[1<<17];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin>>N>>K>>M>>P;
	for(int i=0;i<M;i++)
	{
		int u,v;cin>>u>>v;
		u--,v--;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	for(int i=0;i<N;i++)
	{
		cin>>S[i];
		inf[i]=-1;
	}
	priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > >Q;
	for(int i=0;i<K;i++)
	{
		int x;cin>>x;x--;
		inf[x]=0;
		Q.push(make_pair(inf[x]+S[x],x));
	}
	int bc=0;
	vector<int>B;
	while(!Q.empty())
	{
		int d=Q.top().first;
		B.clear();
		while(!Q.empty()&&Q.top().first==d)
		{
			int x=Q.top().second;
			Q.pop();
			if(ban[x])continue;
			for(int v:G[x])
			{
				if(inf[v]==-1)
				{
					inf[v]=d;
					Q.push(make_pair(inf[v]+S[v],v));
				}
				else if(inf[v]+P>d&&!ban[v])B.push_back(v);
			}
		}
		for(int v:B)
		{
			bc+=!ban[v];
			ban[v]=true;
		}
	}
	cout<<bc<<endl;
}
0