結果

問題 No.1382 Travel in Mitaru city
ユーザー norikamenorikame
提出日時 2021-02-07 22:01:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,195 bytes
コンパイル時間 2,405 ms
コンパイル使用メモリ 210,864 KB
実行使用メモリ 60,124 KB
最終ジャッジ日時 2023-09-17 21:38:41
合計ジャッジ時間 13,956 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 153 ms
9,720 KB
testcase_27 WA -
testcase_28 AC 152 ms
9,688 KB
testcase_29 AC 153 ms
9,656 KB
testcase_30 AC 152 ms
9,740 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 153 ms
8,684 KB
testcase_37 AC 21 ms
4,376 KB
testcase_38 AC 167 ms
9,080 KB
testcase_39 AC 50 ms
4,656 KB
testcase_40 AC 77 ms
7,748 KB
testcase_41 AC 86 ms
8,320 KB
testcase_42 AC 104 ms
9,444 KB
testcase_43 AC 88 ms
8,532 KB
testcase_44 AC 37 ms
5,136 KB
testcase_45 AC 80 ms
8,004 KB
testcase_46 AC 202 ms
19,196 KB
testcase_47 AC 652 ms
35,644 KB
testcase_48 AC 733 ms
58,816 KB
testcase_49 AC 775 ms
60,124 KB
testcase_50 AC 704 ms
56,292 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 AC 4 ms
4,376 KB
testcase_62 AC 2 ms
4,376 KB
testcase_63 AC 16 ms
4,380 KB
testcase_64 AC 6 ms
4,380 KB
testcase_65 AC 2 ms
4,380 KB
testcase_66 AC 5 ms
4,376 KB
testcase_67 AC 4 ms
4,376 KB
testcase_68 AC 8 ms
4,376 KB
testcase_69 AC 3 ms
4,376 KB
testcase_70 AC 8 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using ll = long long;
using ull = unsigned long long;
#define v(t) vector<t>
#define p(t) pair<t, t>
#define p2(t, s) pair<t, s>
#define vp(t) v(p(t))

#define rep(i, n) for (int i=0,i##_len=((int)(n)); i<i##_len; ++i)
#define rep2(i, a, n) for (int i=((int)(a)),i##_len=((int)(n)); i<=i##_len; ++i)
#define repr(i, n) for (int i=((int)(n)-1); i>=0; --i)
#define rep2r(i, a, n) for (int i=((int)(n)),i##_len=((int)(a)); i>=i##_len; --i)

#define repi(itr, c) for (__typeof((c).begin()) itr=(c).begin(); itr!=(c).end(); ++itr)
#define repir(itr, c) for (__typeof((c).rbegin()) itr=(c).rbegin(); itr!=(c).rend(); ++itr)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define eb emplace_back

#define INF (1e9)
#define LINF (1e18)
#define PI (acos(-1))
#define EPS (1e-7)
#define DEPS (1e-10)

int main(){
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    --s; --t;
    v(int) pi(n);
    rep(i, n) cin >> pi[i];
    v(v(int)) g(n);
    rep(i, m) {
        int ai, bi;
        cin >> ai >> bi;
        ai--; bi--;
        g[ai].pb(bi);
        g[bi].pb(ai);
    }
    vp(int) dist(n, {-1,-1});
    priority_queue<p2(p(int),int)> que;
    que.emplace(make_pair(0,pi[s]), s);
    dist[s] = { 0, pi[s] };
    while (!que.empty()) {
        auto p1 = que.top(); que.pop();
        int vy = p1.first.first, vx = p1.first.second, vi = p1.second;
        if (dist[vi] != p(int){vy,vx}) continue;
        rep(i, sz(g[vi])) {
            int ni = g[vi][i], ny, nx;
            if (vx > pi[ni]) {
                ny = vy + 1;
                nx = pi[ni];
            }
            else {
                ny = vy;
                nx = vx;
            }
            if (dist[ni].first>ny||(dist[ni].first==ny&&dist[ni].second>=nx)) continue;
            que.emplace(make_pair(ny, nx), ni);
            dist[ni] = { ny, nx };
        }
    }
    cout << dist[t].first << endl;
    return 0;
}
0