結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー queeequeee
提出日時 2020-05-29 23:07:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 329 ms / 2,000 ms
コード長 1,667 bytes
コンパイル時間 786 ms
コンパイル使用メモリ 93,172 KB
実行使用メモリ 19,200 KB
最終ジャッジ日時 2024-04-24 00:56:30
合計ジャッジ時間 7,926 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 148 ms
11,640 KB
testcase_03 AC 228 ms
16,908 KB
testcase_04 AC 239 ms
16,904 KB
testcase_05 AC 202 ms
16,780 KB
testcase_06 AC 194 ms
16,912 KB
testcase_07 AC 69 ms
7,936 KB
testcase_08 AC 275 ms
19,016 KB
testcase_09 AC 26 ms
5,376 KB
testcase_10 AC 117 ms
10,624 KB
testcase_11 AC 80 ms
8,576 KB
testcase_12 AC 41 ms
5,376 KB
testcase_13 AC 146 ms
10,880 KB
testcase_14 AC 179 ms
14,028 KB
testcase_15 AC 208 ms
15,364 KB
testcase_16 AC 94 ms
7,996 KB
testcase_17 AC 227 ms
16,088 KB
testcase_18 AC 69 ms
6,528 KB
testcase_19 AC 215 ms
16,416 KB
testcase_20 AC 57 ms
6,984 KB
testcase_21 AC 82 ms
6,528 KB
testcase_22 AC 196 ms
14,696 KB
testcase_23 AC 4 ms
5,376 KB
testcase_24 AC 4 ms
5,376 KB
testcase_25 AC 35 ms
5,376 KB
testcase_26 AC 108 ms
10,204 KB
testcase_27 AC 112 ms
9,208 KB
testcase_28 AC 196 ms
13,332 KB
testcase_29 AC 24 ms
5,376 KB
testcase_30 AC 213 ms
15,672 KB
testcase_31 AC 144 ms
13,280 KB
testcase_32 AC 94 ms
9,464 KB
testcase_33 AC 213 ms
17,656 KB
testcase_34 AC 71 ms
6,956 KB
testcase_35 AC 211 ms
15,500 KB
testcase_36 AC 3 ms
5,376 KB
testcase_37 AC 4 ms
5,376 KB
testcase_38 AC 3 ms
5,376 KB
testcase_39 AC 3 ms
5,376 KB
testcase_40 AC 2 ms
5,376 KB
testcase_41 AC 329 ms
19,200 KB
testcase_42 AC 92 ms
8,448 KB
testcase_43 AC 166 ms
12,032 KB
testcase_44 AC 59 ms
6,784 KB
testcase_45 AC 155 ms
11,648 KB
testcase_46 AC 2 ms
5,376 KB
testcase_47 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <functional>
#define DB puts("D")
#define pb push_back

using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";}
template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";}
template<typename T> void caut(T a){cout<<"("<<a<<") ";}
template<typename T> void input(T a[], int n){for(int i=0;i<n;i++) cin>>a[i];}
template<typename T, typename U> void input(T a[], U b[], int n){for(int i=0;i<n;i++) cin>>a[i]>>b[i];}
template<typename T, typename U, typename O> void input(T a[], U b[], O[], int n){for(int i=0;i<n;i++) cin>>a[i]>>b[i];}

using P=pair<double,int>;

int main() {
  int n,m; cin>>n>>m;
  int x,y; cin>>x>>y; x--; y--;
  double p[n],q[n]; input(p,q,n);
  vector<int> v[n];
  for(int i=0;i<m;i++) {
    int a,b; cin>>a>>b;; a--;b--;
    v[a].push_back(b); v[b].push_back(a);
  }
  
  priority_queue<P, vector<P>, greater<P>> que; que.push({0,x});
  double an[n]; fill(an,an+n,dINF); an[x]=0;
  while(!que.empty()) {
    P top = que.top(); que.pop();
    int f = top.second;
    if (top.first - EPS > an[top.second]) continue;
    for(int x : v[f]) {
      double dis = sqrt((p[x]-p[f])*(p[x]-p[f])+(q[x]-q[f])*(q[x]-q[f]));
      if (an[x] > an[f] + dis) {
        an[x] = an[f] + dis;
        que.push({an[x], x});
      }
    }
  }
  cout.precision(10);
  cout<<an[y]<<endl;
}
0