結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
5,964 KB
testcase_01 AC 4 ms
5,780 KB
testcase_02 AC 3 ms
5,900 KB
testcase_03 AC 4 ms
5,756 KB
testcase_04 AC 3 ms
5,776 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 22 ms
7,116 KB
testcase_08 WA -
testcase_09 AC 29 ms
7,340 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 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 66 ms
9,876 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 AC 3 ms
5,820 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 #

// 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.leader(u) == d.leader(S); })){
                ++ans;
            }
        }
        for(int w: g[t]){
            d.merge(w, t);
        }
    }
    print(ans);
}
0