結果

問題 No.1382 Travel in Mitaru city
ユーザー chocoruskchocorusk
提出日時 2021-02-09 20:04:43
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 133 ms / 2,000 ms
コード長 1,270 bytes
コンパイル時間 1,955 ms
コンパイル使用メモリ 133,432 KB
実行使用メモリ 10,240 KB
最終ジャッジ日時 2023-09-21 07:46:55
合計ジャッジ時間 12,767 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,032 KB
testcase_01 AC 2 ms
5,780 KB
testcase_02 AC 3 ms
5,960 KB
testcase_03 AC 3 ms
5,796 KB
testcase_04 AC 3 ms
5,860 KB
testcase_05 AC 3 ms
6,100 KB
testcase_06 AC 54 ms
7,572 KB
testcase_07 AC 44 ms
7,088 KB
testcase_08 AC 24 ms
6,448 KB
testcase_09 AC 60 ms
7,656 KB
testcase_10 AC 56 ms
7,560 KB
testcase_11 AC 80 ms
8,156 KB
testcase_12 AC 85 ms
7,996 KB
testcase_13 AC 91 ms
8,120 KB
testcase_14 AC 76 ms
7,924 KB
testcase_15 AC 81 ms
8,012 KB
testcase_16 AC 130 ms
9,040 KB
testcase_17 AC 129 ms
9,240 KB
testcase_18 AC 128 ms
9,168 KB
testcase_19 AC 127 ms
9,192 KB
testcase_20 AC 125 ms
9,036 KB
testcase_21 AC 127 ms
9,084 KB
testcase_22 AC 126 ms
9,140 KB
testcase_23 AC 125 ms
9,088 KB
testcase_24 AC 127 ms
9,296 KB
testcase_25 AC 129 ms
9,148 KB
testcase_26 AC 132 ms
9,032 KB
testcase_27 AC 126 ms
9,148 KB
testcase_28 AC 130 ms
9,088 KB
testcase_29 AC 133 ms
9,292 KB
testcase_30 AC 125 ms
9,084 KB
testcase_31 AC 94 ms
8,700 KB
testcase_32 AC 117 ms
9,296 KB
testcase_33 AC 108 ms
8,996 KB
testcase_34 AC 74 ms
8,120 KB
testcase_35 AC 50 ms
7,256 KB
testcase_36 AC 87 ms
8,872 KB
testcase_37 AC 16 ms
6,328 KB
testcase_38 AC 96 ms
9,064 KB
testcase_39 AC 26 ms
6,892 KB
testcase_40 AC 73 ms
8,244 KB
testcase_41 AC 80 ms
8,820 KB
testcase_42 AC 97 ms
9,092 KB
testcase_43 AC 84 ms
8,616 KB
testcase_44 AC 35 ms
6,892 KB
testcase_45 AC 77 ms
8,580 KB
testcase_46 AC 32 ms
6,984 KB
testcase_47 AC 113 ms
10,076 KB
testcase_48 AC 77 ms
8,804 KB
testcase_49 AC 124 ms
10,240 KB
testcase_50 AC 57 ms
7,952 KB
testcase_51 AC 90 ms
8,776 KB
testcase_52 AC 104 ms
9,248 KB
testcase_53 AC 26 ms
6,644 KB
testcase_54 AC 47 ms
7,480 KB
testcase_55 AC 103 ms
9,180 KB
testcase_56 AC 34 ms
7,112 KB
testcase_57 AC 68 ms
8,068 KB
testcase_58 AC 13 ms
6,148 KB
testcase_59 AC 33 ms
7,000 KB
testcase_60 AC 102 ms
9,268 KB
testcase_61 AC 5 ms
6,064 KB
testcase_62 AC 4 ms
5,796 KB
testcase_63 AC 15 ms
6,280 KB
testcase_64 AC 6 ms
6,008 KB
testcase_65 AC 3 ms
5,896 KB
testcase_66 AC 5 ms
5,956 KB
testcase_67 AC 5 ms
5,872 KB
testcase_68 AC 7 ms
6,256 KB
testcase_69 AC 5 ms
5,888 KB
testcase_70 AC 9 ms
6,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <stack>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int n, m, s, t;
    cin>>n>>m>>s>>t;
    int p[100010];
    for(int i=0; i<n; i++){
        cin>>p[i];
    }
    s--; t--;
    vector<int> g[100010];
    for(int i=0; i<m; i++){
        int a, b; cin>>a>>b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    priority_queue<P> que;
    que.push({p[s], s});
    bool used[100010]={};
    used[s]=1;
    int cnt=0, val=p[s];
    while(!que.empty()){
        P q=que.top(); que.pop();
        if(val>q.first){
            val=q.first;
            cnt++;
        }
        int x=q.second;
        for(auto y:g[x]){
            if(!used[y]){
                used[y]=1;
                que.push({p[y], y});
            }
        }
    }
    cout<<cnt<<endl;
    return 0;
}
0