結果

問題 No.1382 Travel in Mitaru city
ユーザー sten_sansten_san
提出日時 2021-02-07 22:01:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 153 ms / 2,000 ms
コード長 1,197 bytes
コンパイル時間 2,225 ms
コンパイル使用メモリ 210,908 KB
実行使用メモリ 10,036 KB
最終ジャッジ日時 2023-09-17 21:37:08
合計ジャッジ時間 11,055 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 71 ms
5,444 KB
testcase_07 AC 54 ms
5,096 KB
testcase_08 AC 27 ms
4,380 KB
testcase_09 AC 77 ms
5,436 KB
testcase_10 AC 72 ms
5,336 KB
testcase_11 AC 90 ms
6,772 KB
testcase_12 AC 98 ms
7,024 KB
testcase_13 AC 104 ms
7,056 KB
testcase_14 AC 85 ms
6,772 KB
testcase_15 AC 90 ms
6,884 KB
testcase_16 AC 148 ms
9,032 KB
testcase_17 AC 144 ms
8,976 KB
testcase_18 AC 150 ms
8,860 KB
testcase_19 AC 149 ms
9,076 KB
testcase_20 AC 148 ms
8,872 KB
testcase_21 AC 152 ms
8,856 KB
testcase_22 AC 152 ms
8,860 KB
testcase_23 AC 148 ms
9,068 KB
testcase_24 AC 151 ms
9,076 KB
testcase_25 AC 153 ms
8,916 KB
testcase_26 AC 153 ms
8,852 KB
testcase_27 AC 150 ms
8,900 KB
testcase_28 AC 151 ms
9,032 KB
testcase_29 AC 153 ms
8,880 KB
testcase_30 AC 147 ms
8,864 KB
testcase_31 AC 100 ms
7,768 KB
testcase_32 AC 119 ms
8,832 KB
testcase_33 AC 116 ms
8,632 KB
testcase_34 AC 77 ms
6,780 KB
testcase_35 AC 50 ms
5,668 KB
testcase_36 AC 86 ms
8,056 KB
testcase_37 AC 15 ms
4,376 KB
testcase_38 AC 95 ms
8,832 KB
testcase_39 AC 26 ms
4,380 KB
testcase_40 AC 74 ms
7,368 KB
testcase_41 AC 82 ms
7,632 KB
testcase_42 AC 99 ms
8,568 KB
testcase_43 AC 85 ms
7,796 KB
testcase_44 AC 34 ms
4,864 KB
testcase_45 AC 76 ms
7,176 KB
testcase_46 AC 34 ms
5,128 KB
testcase_47 AC 130 ms
9,728 KB
testcase_48 AC 88 ms
7,732 KB
testcase_49 AC 137 ms
10,036 KB
testcase_50 AC 59 ms
6,488 KB
testcase_51 AC 96 ms
8,160 KB
testcase_52 AC 115 ms
9,096 KB
testcase_53 AC 25 ms
4,412 KB
testcase_54 AC 50 ms
5,668 KB
testcase_55 AC 108 ms
8,688 KB
testcase_56 AC 34 ms
4,840 KB
testcase_57 AC 70 ms
7,008 KB
testcase_58 AC 12 ms
4,380 KB
testcase_59 AC 35 ms
4,832 KB
testcase_60 AC 105 ms
8,524 KB
testcase_61 AC 4 ms
4,380 KB
testcase_62 AC 1 ms
4,376 KB
testcase_63 AC 20 ms
4,376 KB
testcase_64 AC 7 ms
4,380 KB
testcase_65 AC 2 ms
4,376 KB
testcase_66 AC 4 ms
4,376 KB
testcase_67 AC 5 ms
4,380 KB
testcase_68 AC 8 ms
4,380 KB
testcase_69 AC 4 ms
4,380 KB
testcase_70 AC 10 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

struct uns_t {} uns;
template <typename Element, typename Head, typename ...Args>
auto vec(Element init, Head arg, Args ...args) {
    if constexpr (sizeof...(Args) == 0) return std::vector(arg, init);
    else return std::vector(arg, vec(init, args...));
}
template <typename Element, typename Head, typename ...Args>
auto vec(uns_t, Head arg, Args ...args) {
    return vec(Element(), arg, args...);
}

int main() {
    int n, m, s, t; cin >> n >> m >> s >> t; --s; --t;
    auto p = vec<int>(uns, n);
    for (auto &e : p) cin >> e;

    auto g = vec<int>(uns, n, 0);
    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);
    }

    int x = p[s], y = 0;

    auto vis = vec<bool>(false, n);
    priority_queue<tuple<int, int>> que;
    que.push({ p[s], s });
    while (!que.empty()) {
        auto [c, u] = que.top(); que.pop();
        if (vis[u]) continue;
        vis[u] = true;

        y += c < x;
        x = min(x, c);

        for (auto v : g[u]) {
            if (vis[v]) continue;
            que.push({ p[v], v });
        }
    }

    cout << y << endl;
}

0