結果

問題 No.1382 Travel in Mitaru city
ユーザー norikamenorikame
提出日時 2021-02-07 21:47:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,198 bytes
コンパイル時間 2,107 ms
コンパイル使用メモリ 211,216 KB
実行使用メモリ 60,408 KB
最終ジャッジ日時 2023-09-17 21:11:27
合計ジャッジ時間 13,317 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 WA -
testcase_04 AC 2 ms
4,380 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 135 ms
9,616 KB
testcase_27 WA -
testcase_28 AC 135 ms
9,688 KB
testcase_29 AC 136 ms
9,624 KB
testcase_30 AC 134 ms
9,644 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 166 ms
8,704 KB
testcase_37 AC 22 ms
4,376 KB
testcase_38 AC 180 ms
9,092 KB
testcase_39 AC 54 ms
4,912 KB
testcase_40 AC 78 ms
7,844 KB
testcase_41 AC 86 ms
8,324 KB
testcase_42 AC 104 ms
9,360 KB
testcase_43 AC 89 ms
8,568 KB
testcase_44 AC 37 ms
5,156 KB
testcase_45 AC 81 ms
8,036 KB
testcase_46 AC 190 ms
17,460 KB
testcase_47 AC 621 ms
35,820 KB
testcase_48 AC 696 ms
56,976 KB
testcase_49 AC 739 ms
60,408 KB
testcase_50 AC 678 ms
56,232 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 WA -
testcase_62 AC 1 ms
4,376 KB
testcase_63 WA -
testcase_64 WA -
testcase_65 WA -
testcase_66 WA -
testcase_67 WA -
testcase_68 WA -
testcase_69 WA -
testcase_70 WA -
権限があれば一括ダウンロードができます

ソースコード

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(int,p(int))> que;
    que.emplace(0, make_pair(s,pi[s]));
    dist[s] = { 0, pi[s] };
    while (!que.empty()) {
        auto p1 = que.top(); que.pop();
        int vy = p1.first, vx = p1.second.second, vi = p1.second.first;
        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(ny, make_pair(ni, nx));
            dist[ni] = { ny, nx };
        }
    }
    cout << dist[t].first << endl;
    return 0;
}
0