結果

問題 No.2431 Viral Hotel
ユーザー kt_soupkt_soup
提出日時 2023-08-18 22:53:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 190 ms / 2,000 ms
コード長 1,090 bytes
コンパイル時間 835 ms
コンパイル使用メモリ 84,268 KB
実行使用メモリ 14,564 KB
最終ジャッジ日時 2024-05-06 05:20:50
合計ジャッジ時間 6,167 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 150 ms
11,232 KB
testcase_01 AC 123 ms
10,632 KB
testcase_02 AC 132 ms
11,192 KB
testcase_03 AC 146 ms
11,968 KB
testcase_04 AC 151 ms
11,936 KB
testcase_05 AC 171 ms
12,960 KB
testcase_06 AC 76 ms
8,576 KB
testcase_07 AC 76 ms
8,452 KB
testcase_08 AC 79 ms
8,452 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 190 ms
14,564 KB
testcase_13 AC 151 ms
11,516 KB
testcase_14 AC 65 ms
7,800 KB
testcase_15 AC 34 ms
5,436 KB
testcase_16 AC 71 ms
8,532 KB
testcase_17 AC 63 ms
6,996 KB
testcase_18 AC 146 ms
12,908 KB
testcase_19 AC 82 ms
8,700 KB
testcase_20 AC 42 ms
6,656 KB
testcase_21 AC 37 ms
5,716 KB
testcase_22 AC 105 ms
9,056 KB
testcase_23 AC 109 ms
8,964 KB
testcase_24 AC 54 ms
7,680 KB
testcase_25 AC 126 ms
10,748 KB
testcase_26 AC 72 ms
8,960 KB
testcase_27 AC 89 ms
8,680 KB
testcase_28 AC 73 ms
7,720 KB
testcase_29 AC 80 ms
7,640 KB
testcase_30 AC 97 ms
8,952 KB
testcase_31 AC 107 ms
9,964 KB
testcase_32 AC 40 ms
5,796 KB
testcase_33 AC 79 ms
7,196 KB
testcase_34 AC 8 ms
5,376 KB
testcase_35 AC 22 ms
5,376 KB
testcase_36 AC 116 ms
11,264 KB
testcase_37 AC 84 ms
8,964 KB
testcase_38 AC 40 ms
6,784 KB
testcase_39 AC 2 ms
5,376 KB
testcase_40 AC 2 ms
5,376 KB
testcase_41 AC 2 ms
5,376 KB
testcase_42 AC 2 ms
5,376 KB
testcase_43 AC 162 ms
14,388 KB
testcase_44 AC 102 ms
9,820 KB
testcase_45 AC 70 ms
7,808 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<queue>
#include<utility>
using namespace std;
int main() {
  int N,K,M,P,u,v,x;
  cin >> N >> K >> M >> P;
  vector<vector<int>> G(N);
  while(M--) {
    cin >> u >> v;
    G[u-1].push_back(v-1);
    G[v-1].push_back(u-1);
  }
  vector<int> s(N);
  for(int i=0;i<N;i++)cin >> s[i];
  priority_queue<pair<long long,pair<int,int>>,vector<pair<long long,pair<int,int>>>,greater<pair<long long,pair<int,int>>>> q;
  while(K--) {
    cin >> x;
    q.push({0,{x-1,x-1}});
  }
  int ans = 0;
  vector<long long> t(N,-1),t2(N,1ll<<60);
  while(!q.empty()) {
    pair<long long,pair<int,int>> p = q.top();
    q.pop();
    if(p.first > t2[p.second.first])continue;
    if(t[p.second.second] < 0) {
      for(int i=0;i<G[p.second.second].size();i++) {
        q.push({p.first+s[p.second.second],{p.second.second,G[p.second.second][i]}});
      }
      t[p.second.second] = p.first;
    }
    else if(t[p.second.second] + P > p.first && t2[p.second.second] == 1ll<<60) {
      ans++;
      t2[p.second.second] = p.first;
    }
  }
  cout << ans << endl;
}
0