結果

問題 No.1382 Travel in Mitaru city
ユーザー outlineoutline
提出日時 2021-02-07 21:20:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,758 bytes
コンパイル時間 1,534 ms
コンパイル使用メモリ 146,460 KB
実行使用メモリ 12,164 KB
最終ジャッジ日時 2023-09-17 20:23:30
合計ジャッジ時間 6,862 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 WA -
testcase_07 AC 19 ms
4,548 KB
testcase_08 WA -
testcase_09 AC 26 ms
4,920 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 56 ms
9,080 KB
testcase_28 AC 54 ms
9,092 KB
testcase_29 AC 55 ms
9,080 KB
testcase_30 AC 54 ms
9,076 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 36 ms
8,288 KB
testcase_37 AC 7 ms
4,380 KB
testcase_38 AC 40 ms
8,860 KB
testcase_39 AC 12 ms
4,588 KB
testcase_40 AC 30 ms
7,492 KB
testcase_41 AC 35 ms
7,952 KB
testcase_42 AC 42 ms
9,100 KB
testcase_43 AC 36 ms
8,004 KB
testcase_44 AC 16 ms
5,144 KB
testcase_45 AC 33 ms
7,760 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 30 ms
7,504 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 2 ms
4,380 KB
testcase_62 AC 1 ms
4,380 KB
testcase_63 AC 6 ms
4,380 KB
testcase_64 AC 3 ms
4,376 KB
testcase_65 AC 1 ms
4,376 KB
testcase_66 AC 2 ms
4,380 KB
testcase_67 AC 2 ms
4,376 KB
testcase_68 AC 4 ms
4,380 KB
testcase_69 AC 2 ms
4,380 KB
testcase_70 AC 4 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <array>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
using namespace std;

using ll = long long;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, m, s, t;
    cin >> n >> m >> s >> t;
    --s, --t;
    vector<int> p(n);
    for(int i = 0; i < n; ++i)  cin >> p[i];
    vector<vector<int>> g(n);
    for(int i = 0; i < m; ++i){
        int a, b;
        cin >> a >> b;
        --a, --b;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }

    vector<int> dist(n, INF);
    dist[s] = 0;
    queue<int> que;
    que.emplace(s);
    while(!que.empty()){
        int from = que.front();
        que.pop();
        for(int to : g[from]){
            if(chmin(dist[to], dist[from] + 1)){
                que.emplace(to);
            }
        }
    }

    set<int> ps;
    for(int i = 0; i < n; ++i){
        if(dist[i] != INF && p[i] < p[s])   ps.emplace(p[i]);
    }

    cout << ps.size() << endl;

    return 0;
}
0