結果

問題 No.1382 Travel in Mitaru city
ユーザー eQeeQe
提出日時 2021-03-07 20:43:16
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 191 ms / 2,000 ms
コード長 1,315 bytes
コンパイル時間 3,804 ms
コンパイル使用メモリ 228,424 KB
実行使用メモリ 13,200 KB
最終ジャッジ日時 2024-04-17 10:44:38
合計ジャッジ時間 12,609 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,016 KB
testcase_01 AC 3 ms
6,144 KB
testcase_02 AC 3 ms
6,016 KB
testcase_03 AC 3 ms
6,016 KB
testcase_04 AC 4 ms
6,144 KB
testcase_05 AC 3 ms
6,144 KB
testcase_06 AC 86 ms
9,428 KB
testcase_07 AC 68 ms
8,760 KB
testcase_08 AC 34 ms
7,024 KB
testcase_09 AC 95 ms
9,748 KB
testcase_10 AC 88 ms
9,632 KB
testcase_11 AC 100 ms
9,856 KB
testcase_12 AC 105 ms
9,856 KB
testcase_13 AC 116 ms
9,856 KB
testcase_14 AC 96 ms
9,140 KB
testcase_15 AC 98 ms
9,472 KB
testcase_16 AC 160 ms
11,392 KB
testcase_17 AC 161 ms
11,392 KB
testcase_18 AC 159 ms
11,344 KB
testcase_19 AC 158 ms
11,264 KB
testcase_20 AC 165 ms
11,392 KB
testcase_21 AC 160 ms
11,392 KB
testcase_22 AC 161 ms
11,264 KB
testcase_23 AC 152 ms
11,264 KB
testcase_24 AC 147 ms
11,392 KB
testcase_25 AC 153 ms
11,392 KB
testcase_26 AC 191 ms
11,264 KB
testcase_27 AC 166 ms
11,264 KB
testcase_28 AC 167 ms
11,264 KB
testcase_29 AC 151 ms
11,392 KB
testcase_30 AC 155 ms
11,264 KB
testcase_31 AC 117 ms
9,600 KB
testcase_32 AC 140 ms
10,308 KB
testcase_33 AC 124 ms
10,112 KB
testcase_34 AC 84 ms
8,576 KB
testcase_35 AC 58 ms
7,680 KB
testcase_36 AC 102 ms
10,852 KB
testcase_37 AC 20 ms
6,900 KB
testcase_38 AC 114 ms
11,156 KB
testcase_39 AC 29 ms
6,784 KB
testcase_40 AC 100 ms
11,092 KB
testcase_41 AC 97 ms
9,472 KB
testcase_42 AC 114 ms
10,112 KB
testcase_43 AC 97 ms
9,408 KB
testcase_44 AC 43 ms
7,168 KB
testcase_45 AC 93 ms
9,088 KB
testcase_46 AC 40 ms
7,808 KB
testcase_47 AC 132 ms
12,708 KB
testcase_48 AC 95 ms
10,352 KB
testcase_49 AC 149 ms
13,200 KB
testcase_50 AC 68 ms
9,448 KB
testcase_51 AC 103 ms
9,728 KB
testcase_52 AC 119 ms
10,364 KB
testcase_53 AC 29 ms
6,784 KB
testcase_54 AC 53 ms
7,808 KB
testcase_55 AC 115 ms
10,240 KB
testcase_56 AC 39 ms
7,296 KB
testcase_57 AC 74 ms
8,704 KB
testcase_58 AC 15 ms
6,528 KB
testcase_59 AC 37 ms
7,040 KB
testcase_60 AC 111 ms
9,984 KB
testcase_61 AC 7 ms
6,144 KB
testcase_62 AC 4 ms
6,144 KB
testcase_63 AC 28 ms
6,824 KB
testcase_64 AC 10 ms
6,400 KB
testcase_65 AC 5 ms
6,144 KB
testcase_66 AC 8 ms
6,016 KB
testcase_67 AC 8 ms
6,016 KB
testcase_68 AC 13 ms
6,528 KB
testcase_69 AC 6 ms
6,272 KB
testcase_70 AC 15 ms
6,656 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define itr(x,c) for(auto x=c.begin();x!=c.end();x++)
#define all(a) (a.begin()),(a.end())
using namespace std;
#include <atcoder/all>
using namespace atcoder;
typedef long long ll;
typedef pair<ll, ll> pll;
template<class T>bool chmax(T &a, const T &b) {if(a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a) {a=b; return 1;} return 0;}
static const ll INF=1e18;
static const ll MAX=101010;
//static const ll MOD=1e9+7;
//static const ll MOD=998244353;
//for(i=0;i<N;i++) cin>>a[i];

typedef vector<ll> v1D;
typedef vector<v1D> v2D;
typedef vector<v2D> v3D;



int main(void) {
  ll i,j,k;
  
  ll N,M,S,T;cin>>N>>M>>S>>T;S--;T--;
  
  vector<ll> a(N);
  for(i=0;i<N;i++)cin>>a[i];
  
  vector<ll> g[MAX];
  for(i=0;i<M;i++){
    ll x,y;cin>>x>>y;x--;y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  
  auto solve=[&](){
    ll res=0;
    ll X=a[S];
    priority_queue<pll> q;
    q.push({a[S],S});
    vector<ll> clr(N,0);
    
    while(q.size()){
      pll p=q.top();q.pop();
      ll u=p.second;
      ll d=p.first;
      
      if(clr[u]) continue;
      clr[u]=1;
      
      res+=chmin(X,d);
      
      for(auto v:g[u]) q.push({a[v],v});
    }
    
    return res;
  };
  
  pt(solve());
  
  
  
}
0