結果

問題 No.1382 Travel in Mitaru city
ユーザー tnakao0123tnakao0123
提出日時 2021-02-08 15:52:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 1,430 bytes
コンパイル時間 1,927 ms
コンパイル使用メモリ 99,684 KB
実行使用メモリ 10,392 KB
最終ジャッジ日時 2023-09-19 06:01:15
合計ジャッジ時間 13,554 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,076 KB
testcase_01 AC 3 ms
5,808 KB
testcase_02 AC 4 ms
5,784 KB
testcase_03 AC 4 ms
5,784 KB
testcase_04 AC 3 ms
6,008 KB
testcase_05 AC 4 ms
5,936 KB
testcase_06 AC 30 ms
7,476 KB
testcase_07 AC 24 ms
7,108 KB
testcase_08 AC 15 ms
6,588 KB
testcase_09 AC 32 ms
7,608 KB
testcase_10 AC 31 ms
7,488 KB
testcase_11 AC 52 ms
8,132 KB
testcase_12 AC 57 ms
8,136 KB
testcase_13 AC 59 ms
8,252 KB
testcase_14 AC 50 ms
7,992 KB
testcase_15 AC 53 ms
7,980 KB
testcase_16 AC 90 ms
9,396 KB
testcase_17 AC 89 ms
9,464 KB
testcase_18 AC 89 ms
9,268 KB
testcase_19 AC 89 ms
9,520 KB
testcase_20 AC 89 ms
9,324 KB
testcase_21 AC 92 ms
9,348 KB
testcase_22 AC 88 ms
9,512 KB
testcase_23 AC 91 ms
9,260 KB
testcase_24 AC 91 ms
9,268 KB
testcase_25 AC 91 ms
9,400 KB
testcase_26 AC 91 ms
9,204 KB
testcase_27 AC 90 ms
9,328 KB
testcase_28 AC 92 ms
9,284 KB
testcase_29 AC 91 ms
9,516 KB
testcase_30 AC 89 ms
9,332 KB
testcase_31 AC 56 ms
8,996 KB
testcase_32 AC 71 ms
9,384 KB
testcase_33 AC 64 ms
9,180 KB
testcase_34 AC 44 ms
8,168 KB
testcase_35 AC 29 ms
7,452 KB
testcase_36 AC 40 ms
8,844 KB
testcase_37 AC 9 ms
6,556 KB
testcase_38 AC 44 ms
9,240 KB
testcase_39 AC 14 ms
6,672 KB
testcase_40 AC 33 ms
8,388 KB
testcase_41 AC 37 ms
8,664 KB
testcase_42 AC 44 ms
9,428 KB
testcase_43 AC 38 ms
9,036 KB
testcase_44 AC 17 ms
7,056 KB
testcase_45 AC 35 ms
8,540 KB
testcase_46 AC 20 ms
6,940 KB
testcase_47 AC 75 ms
10,136 KB
testcase_48 AC 48 ms
8,752 KB
testcase_49 AC 79 ms
10,392 KB
testcase_50 AC 35 ms
7,736 KB
testcase_51 AC 55 ms
8,928 KB
testcase_52 AC 67 ms
9,448 KB
testcase_53 AC 15 ms
6,788 KB
testcase_54 AC 30 ms
7,612 KB
testcase_55 AC 64 ms
9,260 KB
testcase_56 AC 21 ms
7,080 KB
testcase_57 AC 41 ms
8,216 KB
testcase_58 AC 9 ms
6,284 KB
testcase_59 AC 20 ms
7,000 KB
testcase_60 AC 61 ms
9,480 KB
testcase_61 AC 4 ms
5,880 KB
testcase_62 AC 4 ms
5,884 KB
testcase_63 AC 9 ms
6,212 KB
testcase_64 AC 5 ms
6,088 KB
testcase_65 AC 3 ms
6,028 KB
testcase_66 AC 5 ms
6,172 KB
testcase_67 AC 5 ms
5,880 KB
testcase_68 AC 6 ms
5,968 KB
testcase_69 AC 5 ms
5,852 KB
testcase_70 AC 6 ms
6,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 1382.cc:  No.1382 Travel in Mitaru city - yukicoder
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

typedef pair<int,int> pii;
typedef vector<int> vi;

/* global variables */

int ps[MAX_N];
vi nbrs[MAX_N];
bool used[MAX_N];

/* subroutines */

/* main */

int main() {
  int n, m, st, gl;
  scanf("%d%d%d%d", &n, &m, &st, &gl);
  st--, gl--;

  for (int i = 0; i < n; i++) scanf("%d", ps + i);

  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--, b--;
    nbrs[a].push_back(b);
    nbrs[b].push_back(a);
  }

  int x = ps[st], y = 0;
  used[st] = true;

  priority_queue<pii> q;
  q.push(pii(ps[st], st));

  while (! q.empty()) {
    pii u = q.top(); q.pop();
    int up = u.first, ui = u.second;
    //printf("u=(%d,%d), x=%d, y=%d\n", up, ui, x, y);

    if (x > up) x = up, y++;
    
    vi &nbru = nbrs[ui];
    for (vi::iterator vit = nbru.begin(); vit != nbru.end(); vit++) {
      int v = *vit;
      if (! used[v]) {
	used[v] = true;
	q.push(pii(ps[v], v));
      }
    }
  }

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