結果
| 問題 |
No.1065 電柱 / Pole (Easy)
|
| コンテスト | |
| ユーザー |
queee
|
| 提出日時 | 2020-05-29 23:06:49 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,644 bytes |
| コンパイル時間 | 924 ms |
| コンパイル使用メモリ | 93,132 KB |
| 実行使用メモリ | 25,784 KB |
| 最終ジャッジ日時 | 2024-11-06 07:29:49 |
| 合計ジャッジ時間 | 5,378 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 1 TLE * 1 -- * 44 |
ソースコード
#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;
}
queee