結果

問題 No.1382 Travel in Mitaru city
ユーザー evimaevima
提出日時 2021-02-17 12:41:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,859 bytes
コンパイル時間 4,962 ms
コンパイル使用メモリ 270,088 KB
実行使用メモリ 10,512 KB
最終ジャッジ日時 2023-10-11 23:59:20
合計ジャッジ時間 11,353 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
5,900 KB
testcase_01 AC 3 ms
5,936 KB
testcase_02 AC 3 ms
5,864 KB
testcase_03 AC 4 ms
6,072 KB
testcase_04 AC 3 ms
5,792 KB
testcase_05 AC 3 ms
5,792 KB
testcase_06 WA -
testcase_07 AC 22 ms
6,972 KB
testcase_08 WA -
testcase_09 AC 29 ms
7,376 KB
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 WA -
testcase_27 AC 78 ms
9,952 KB
testcase_28 AC 75 ms
9,848 KB
testcase_29 AC 75 ms
9,952 KB
testcase_30 AC 68 ms
9,896 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 40 ms
9,492 KB
testcase_37 AC 9 ms
6,440 KB
testcase_38 AC 44 ms
9,788 KB
testcase_39 AC 13 ms
6,824 KB
testcase_40 AC 34 ms
8,968 KB
testcase_41 AC 42 ms
9,224 KB
testcase_42 AC 50 ms
9,844 KB
testcase_43 AC 43 ms
9,356 KB
testcase_44 AC 19 ms
7,116 KB
testcase_45 AC 39 ms
9,140 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 40 ms
8,580 KB
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 AC 4 ms
5,844 KB
testcase_62 AC 3 ms
5,976 KB
testcase_63 AC 9 ms
6,076 KB
testcase_64 AC 5 ms
5,924 KB
testcase_65 AC 4 ms
5,848 KB
testcase_66 AC 5 ms
5,824 KB
testcase_67 AC 4 ms
5,940 KB
testcase_68 AC 5 ms
5,988 KB
testcase_69 AC 4 ms
5,836 KB
testcase_70 AC 6 ms
6,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// Enjoy your stay. Code by evima

#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;// modint1000000007;// modint;

#include <bits/stdc++.h>

#define LOOPVAR_TYPE long long

#define all(x) (x).begin(), (x).end()
#define sz(x) ((LOOPVAR_TYPE)(x).size())
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define print(x) cout << (x) << endl
#define _rep(i, n) _rep2(i, 0, n)
#define _rep2(i, a, b) for(LOOPVAR_TYPE i = (LOOPVAR_TYPE)(a); i < (LOOPVAR_TYPE)(b); i++)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)

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

#define eb emplace_back
#define fir first
#define sec second
#define mp make_pair
#define mt make_tuple

const long double EPS = 1e-9;
const long double PI = 3.14159265358979323846L;
const long long INF = 1070000000LL;
const long long MOD = 998244353LL;// 1000000007LL;

using namespace std;
using ld = long double;
using ll = long long;

void quit(const string& s) { print(s); exit(0); }

int N, M, S, T, p[100010];
vector<int> g[100010];

int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    
    cin >> N >> M >> S >> T, --S;
    rep(i, N) cin >> p[i];
    rep(i, M){
        int a, b;
        cin >> a >> b, --a, --b;
        g[a].eb(b);
        g[b].eb(a);
    }

    vector<pair<int, int>> v;
    rep(i, N){
        v.eb(p[i], i);
    }
    sort(all(v));
    reverse(all(v));
    
    dsu d(N);
    int ans = 0, Y = p[S];
    for(auto [q, t]: v){
        if(q < Y){
            if(any_of(all(g[t]), [&](int u){ return d.same(u, S); })){
                ++ans;
                Y = q;
            }
        }
        for(int w: g[t]){
            d.merge(w, t);
        }
    }
    print(ans);
}
0