結果
| 問題 |
No.2431 Viral Hotel
|
| コンテスト | |
| ユーザー |
momoyuu
|
| 提出日時 | 2023-08-18 21:57:10 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 152 ms / 2,000 ms |
| コード長 | 1,434 bytes |
| コンパイル時間 | 2,922 ms |
| コンパイル使用メモリ | 257,352 KB |
| 実行使用メモリ | 13,420 KB |
| 最終ジャッジ日時 | 2024-11-28 06:56:41 |
| 合計ジャッジ時間 | 7,760 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 42 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
ll n,k,m,p;
cin>>n>>k>>m>>p;
vector<vector<int>> g(n);
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);
}
vector<int> now(n,0);
vector<int> s(n);
for(int i = 0;i<n;i++) cin>>s[i];
using dat = pair<ll,pair<int,int>>;
priority_queue<dat,vector<dat>,greater<dat>> que;
for(int i = 0;i<k;i++){
int x;
cin>>x;
x--;
now[x] = 1;
que.push(make_pair(s[x],make_pair(1,x)));
que.push(make_pair(p,make_pair(0,x)));
}
int ans = 0;
while(que.size()){
auto nown = que.top();
que.pop();
ll d = nown.first;
int t = nown.second.first;
int ni = nown.second.second;
if(t==1){
if(now[ni]<0){
if(-now[ni]<d) continue;
}
for(auto&to:g[ni]){
if(now[to]==0){
now[to] = 1;
que.push(make_pair(d+s[to],make_pair(1,to)));
que.push(make_pair(d+p,make_pair(0,to)));
}else if(now[to]==1){
now[to] = -d;
ans++;
}
}
}else if(t==0){
if(now[ni]<0) continue;
now[ni] = 2;
}
}
cout<<ans<<endl;
}
momoyuu