結果

問題 No.1382 Travel in Mitaru city
ユーザー ぷらぷら
提出日時 2021-02-07 21:10:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,825 bytes
コンパイル時間 1,902 ms
コンパイル使用メモリ 183,392 KB
実行使用メモリ 17,480 KB
最終ジャッジ日時 2023-09-17 20:10:27
合計ジャッジ時間 14,020 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 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 252 ms
17,108 KB
testcase_27 WA -
testcase_28 AC 251 ms
17,140 KB
testcase_29 AC 249 ms
17,216 KB
testcase_30 AC 238 ms
17,000 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
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 WA -
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>
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define rrep(i,n) for(int i = int(n)-1; i >= 0; i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
template<class T> bool chmax(T &a, const T &b) {if(a < b) {a = b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b) {if(b < a) {a = b; return true;} return false;}
int dx[] = {1, 0,-1, 0, 1, 1,-1,-1};
int dy[] = {0, 1, 0,-1, 1,-1, 1,-1};
ll mod = 998244353;
ll MOD = 1000000007;
ll inf = 1001001001;
ll INF = 1001001001001001001;
int dp[100005];
int main() {
    int N,M,S,T;
    cin >> N >> M >> S >> T;
    vector<P>p(N);
    int mx = 0;
    rep(i,N) {
        cin >> p[i].first;
        p[i].second = i;
        if(i+1 == S) {
            mx = (int)p[i].first;
        }
    }
    vector<vector<P>>road(N);
    rep(i,M) {
        int a,b;
        cin >> a >> b;
        a--;b--;
        if(p[a].first > p[b].first) {
            road[a].pb({b,1});
            road[b].pb({a,0});
        }
        else if(p[a].first < p[b].first){
            road[b].pb({a,1});
            road[a].pb({b,0});
        }
        else {
            road[a].pb({b,0});
            road[b].pb({a,0});
        }
    }
    rep(i,N) {
        if(p[i].first > mx) {
            p[i].first = -1;
        }
    }
    S--;T--;
    sort(rall(p));
    map<int,int>key;
    int k = 1000000;
    rep(i,N) {
        key[(int)p[i].second] = i;
        if(p[i].first == mx) {
            chmin(k,i);
        }
    }
    for(int i = 0; i < N; i++) {
        rep(j,road[p[i].second].size()) {
            chmax(dp[key[(int)road[p[i].second][j].first]],(int)(dp[i]+road[p[i].second][j].second));
        }
    }
    cout << dp[key[(int)T]] << endl;
}
0