結果

問題 No.1382 Travel in Mitaru city
ユーザー RheoTommyRheoTommy
提出日時 2021-02-07 23:09:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 218 ms / 2,000 ms
コード長 1,248 bytes
コンパイル時間 3,043 ms
コンパイル使用メモリ 214,792 KB
実行使用メモリ 15,936 KB
最終ジャッジ日時 2023-09-18 00:43:46
合計ジャッジ時間 13,517 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 83 ms
6,196 KB
testcase_07 AC 64 ms
5,388 KB
testcase_08 AC 34 ms
4,648 KB
testcase_09 AC 95 ms
6,336 KB
testcase_10 AC 87 ms
6,204 KB
testcase_11 AC 133 ms
9,812 KB
testcase_12 AC 142 ms
10,096 KB
testcase_13 AC 152 ms
10,308 KB
testcase_14 AC 125 ms
9,484 KB
testcase_15 AC 127 ms
9,840 KB
testcase_16 AC 214 ms
13,596 KB
testcase_17 AC 216 ms
13,632 KB
testcase_18 AC 210 ms
13,788 KB
testcase_19 AC 218 ms
13,688 KB
testcase_20 AC 213 ms
13,736 KB
testcase_21 AC 218 ms
13,516 KB
testcase_22 AC 216 ms
13,564 KB
testcase_23 AC 211 ms
13,564 KB
testcase_24 AC 211 ms
13,620 KB
testcase_25 AC 210 ms
13,520 KB
testcase_26 AC 215 ms
13,636 KB
testcase_27 AC 212 ms
13,640 KB
testcase_28 AC 214 ms
13,588 KB
testcase_29 AC 212 ms
13,764 KB
testcase_30 AC 211 ms
13,628 KB
testcase_31 AC 159 ms
11,964 KB
testcase_32 AC 192 ms
13,792 KB
testcase_33 AC 172 ms
12,916 KB
testcase_34 AC 110 ms
10,108 KB
testcase_35 AC 73 ms
7,628 KB
testcase_36 AC 124 ms
12,168 KB
testcase_37 AC 19 ms
4,528 KB
testcase_38 AC 137 ms
13,260 KB
testcase_39 AC 34 ms
5,572 KB
testcase_40 AC 104 ms
10,548 KB
testcase_41 AC 115 ms
11,412 KB
testcase_42 AC 142 ms
13,260 KB
testcase_43 AC 118 ms
12,072 KB
testcase_44 AC 47 ms
6,668 KB
testcase_45 AC 107 ms
11,096 KB
testcase_46 AC 43 ms
6,616 KB
testcase_47 AC 176 ms
14,752 KB
testcase_48 AC 114 ms
11,372 KB
testcase_49 AC 186 ms
15,936 KB
testcase_50 AC 80 ms
8,896 KB
testcase_51 AC 149 ms
12,152 KB
testcase_52 AC 177 ms
13,892 KB
testcase_53 AC 36 ms
5,572 KB
testcase_54 AC 74 ms
7,900 KB
testcase_55 AC 173 ms
13,432 KB
testcase_56 AC 51 ms
6,628 KB
testcase_57 AC 109 ms
10,192 KB
testcase_58 AC 17 ms
4,376 KB
testcase_59 AC 49 ms
6,356 KB
testcase_60 AC 163 ms
13,264 KB
testcase_61 AC 4 ms
4,380 KB
testcase_62 AC 2 ms
4,376 KB
testcase_63 AC 15 ms
4,376 KB
testcase_64 AC 5 ms
4,376 KB
testcase_65 AC 2 ms
4,384 KB
testcase_66 AC 4 ms
4,376 KB
testcase_67 AC 4 ms
4,380 KB
testcase_68 AC 7 ms
4,376 KB
testcase_69 AC 3 ms
4,380 KB
testcase_70 AC 8 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (int) n; i++)

using ll = long long;
using namespace std;
using T = tuple<ll, ll, ll>;
using P = pair<ll, ll>;

const long long INF = 1ll << 60;

template<class T>
bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


int main() {
    ll n, m, s, t;
    cin >> n >> m >> s >> t;
    s--;
    t--;
    vector<ll> p(n);
    rep(i, n) cin >> p[i];
    vector<vector<ll>> vertex(n);
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        vertex[a].push_back(b);
        vertex[b].push_back(a);
    }
    
    ll ans = 0;
    ll x = p[s];
    set<ll> st;
    priority_queue<P> pri;
    st.insert(s);
    pri.emplace(p[s], s);
    while (!pri.empty()) {
        auto[pi, i] = pri.top();
        pri.pop();
        if (x > pi) {
            ans++;
            x = p[i];
        }
        for (auto j:vertex[i]) {
            if (st.find(j) == st.end()) {
                st.insert(j);
                pri.emplace(p[j], j);
            }
        }
    }
    
    cout << ans << endl;
}
0