結果

問題 No.2431 Viral Hotel
ユーザー Nzt3Nzt3
提出日時 2023-08-19 02:24:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,156 bytes
コンパイル時間 2,386 ms
コンパイル使用メモリ 210,332 KB
実行使用メモリ 11,552 KB
最終ジャッジ日時 2024-05-06 09:34:59
合計ジャッジ時間 5,629 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 15 ms
5,376 KB
testcase_08 AC 16 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 5 ms
5,376 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 1 ms
5,376 KB
testcase_40 AC 2 ms
5,376 KB
testcase_41 AC 1 ms
5,376 KB
testcase_42 AC 2 ms
5,376 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N,K,M,P;
  cin>>N>>K>>M>>P;
  vector<vector<int>>G(N);
  for(int i=0;i<M;i++){
    int A,B;
    cin>>A>>B;
    --A,--B;
    G[A].push_back(B);
    G[B].push_back(A);
  }
  vector<int>S(N);
  for(int &i:S)cin>>i;
  vector<int>dist(N,(int)1e9),v_cnt(N,0),kansen(N,0);
  priority_queue<array<int,3>,vector<array<int,3>>,greater<array<int,3>>>pq;
  for(int i=0;i<K;i++){
    int T;
    cin>>T;
    --T;
    dist[T]=0;
    pq.push({0,0,T});
  }
  while(pq.size()){
    int d=pq.top()[0],t=pq.top()[1],v=pq.top()[2];
    pq.pop();
    if(v_cnt[v]>=2)continue;
    if(t==0){
      if(d<dist[v]+P){
        v_cnt[v]+=1;
      }
      if(d>dist[v])continue;
      pq.push({d+S[v],1,v});
    }else if(t==1){
      if(kansen[v])continue;
      if(d>dist[v]+S[v])continue;
      kansen[v]=1;
      for(int i:G[v]){
        if(dist[i]+P>d){
          pq.push({d,0,i});
          if(dist[i]>d){
            dist[i]=d;
          }
        }
      }
    }
  }
  int ans=0;
  for(int i:v_cnt){
    if(i>=2)ans+=1;
  }
  cout<<ans<<'\n';
}
0