結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー queeequeee
提出日時 2020-05-29 23:06:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,644 bytes
コンパイル時間 1,007 ms
コンパイル使用メモリ 92,784 KB
実行使用メモリ 24,332 KB
最終ジャッジ日時 2024-04-24 00:55:08
合計ジャッジ時間 5,267 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,752 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 178 ms
11,392 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
権限があれば一括ダウンロードができます

ソースコード

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> 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