結果
問題 | No.2431 Viral Hotel |
ユーザー |
|
提出日時 | 2023-08-19 02:17:16 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,096 bytes |
コンパイル時間 | 2,285 ms |
コンパイル使用メモリ | 202,336 KB |
最終ジャッジ日時 | 2025-02-16 11:19:46 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 4 WA * 38 |
ソースコード
#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); 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(d>dist[v]+S[v])continue; 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'; }