結果

問題 No.1382 Travel in Mitaru city
ユーザー 👑 NachiaNachia
提出日時 2021-02-07 22:53:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 725 bytes
コンパイル時間 2,176 ms
コンパイル使用メモリ 205,344 KB
実行使用メモリ 10,140 KB
最終ジャッジ日時 2023-09-18 00:04:58
合計ジャッジ時間 8,925 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,724 KB
testcase_01 AC 3 ms
5,804 KB
testcase_02 AC 3 ms
5,760 KB
testcase_03 AC 4 ms
5,792 KB
testcase_04 AC 3 ms
5,812 KB
testcase_05 AC 3 ms
5,752 KB
testcase_06 AC 30 ms
7,308 KB
testcase_07 AC 23 ms
6,900 KB
testcase_08 AC 15 ms
6,448 KB
testcase_09 AC 32 ms
7,640 KB
testcase_10 AC 30 ms
7,348 KB
testcase_11 AC 51 ms
8,020 KB
testcase_12 AC 55 ms
8,216 KB
testcase_13 AC 56 ms
8,152 KB
testcase_14 AC 48 ms
7,956 KB
testcase_15 AC 51 ms
8,008 KB
testcase_16 AC 86 ms
9,208 KB
testcase_17 AC 89 ms
9,204 KB
testcase_18 AC 88 ms
9,228 KB
testcase_19 AC 85 ms
9,308 KB
testcase_20 AC 89 ms
9,196 KB
testcase_21 AC 86 ms
9,176 KB
testcase_22 AC 92 ms
9,172 KB
testcase_23 AC 92 ms
9,112 KB
testcase_24 AC 86 ms
9,152 KB
testcase_25 AC 83 ms
9,192 KB
testcase_26 AC 87 ms
9,172 KB
testcase_27 AC 87 ms
9,208 KB
testcase_28 AC 88 ms
9,220 KB
testcase_29 AC 89 ms
9,220 KB
testcase_30 AC 85 ms
9,340 KB
testcase_31 AC 55 ms
8,796 KB
testcase_32 AC 71 ms
9,388 KB
testcase_33 AC 63 ms
9,316 KB
testcase_34 AC 42 ms
8,164 KB
testcase_35 AC 28 ms
7,352 KB
testcase_36 AC 39 ms
8,788 KB
testcase_37 AC 9 ms
6,448 KB
testcase_38 AC 44 ms
9,248 KB
testcase_39 AC 14 ms
6,664 KB
testcase_40 AC 34 ms
8,336 KB
testcase_41 AC 37 ms
8,720 KB
testcase_42 AC 44 ms
9,252 KB
testcase_43 AC 38 ms
8,744 KB
testcase_44 AC 18 ms
6,908 KB
testcase_45 AC 35 ms
8,492 KB
testcase_46 AC 20 ms
6,852 KB
testcase_47 AC 73 ms
9,988 KB
testcase_48 AC 48 ms
8,760 KB
testcase_49 AC 81 ms
10,140 KB
testcase_50 AC 34 ms
7,660 KB
testcase_51 AC 55 ms
8,820 KB
testcase_52 AC 65 ms
9,392 KB
testcase_53 AC 15 ms
6,652 KB
testcase_54 AC 28 ms
7,400 KB
testcase_55 AC 63 ms
9,192 KB
testcase_56 AC 20 ms
7,044 KB
testcase_57 AC 40 ms
8,164 KB
testcase_58 AC 9 ms
6,240 KB
testcase_59 AC 21 ms
6,956 KB
testcase_60 AC 60 ms
9,196 KB
testcase_61 AC 4 ms
5,900 KB
testcase_62 AC 3 ms
5,900 KB
testcase_63 AC 9 ms
6,056 KB
testcase_64 AC 5 ms
6,052 KB
testcase_65 AC 4 ms
5,808 KB
testcase_66 AC 4 ms
6,032 KB
testcase_67 AC 4 ms
5,876 KB
testcase_68 AC 5 ms
5,944 KB
testcase_69 AC 4 ms
6,020 KB
testcase_70 AC 6 ms
5,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

int N,M,S,T;
int P[100000];
vector<int> E[100000];
bool F[100000];

int main(){
  scanf("%d%d%d%d",&N,&M,&S,&T); S--; T--;
  rep(i,N) scanf("%d",&P[i]);
  rep(i,M){
    int u,v; scanf("%d%d",&u,&v); u--; v--;
    E[u].push_back(v);
    E[v].push_back(u);
  }

  rep(i,N) F[i]=false;
  priority_queue<pair<int,int>> Q;
  F[S]=true; Q.push({P[S],S});
  int X=P[S];
  int Y=0;
  while(Q.size()){
    int p=Q.top().second; Q.pop();
    if(X>P[p]){ X=P[p]; Y++; }
    for(int e:E[p]){
      if(F[e]) continue; F[e]=true;
      Q.push({P[e],e});
    }
  }

  printf("%d\n",Y);
  return 0;
}
0