結果
| 問題 |
No.1065 電柱 / Pole (Easy)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-05-29 22:07:36 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 365 ms / 2,000 ms |
| コード長 | 967 bytes |
| コンパイル時間 | 2,117 ms |
| コンパイル使用メモリ | 179,764 KB |
| 実行使用メモリ | 22,672 KB |
| 最終ジャッジ日時 | 2024-11-06 04:58:41 |
| 合計ジャッジ時間 | 9,558 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 46 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<double,int>;
vector<ll> g[2*100000];
vector<pair<ll,ll>> vp;
double G[200000];
int n,m;
int X,Y;
int main()
{
cin >> n >> m;
cin >> X >> Y;
X--;Y--;
for(int i = 0;i < n;i++)
{
int x,y;
cin >> x >> y;
vp.emplace_back(x,y);
}
for(int i = 0;i<m;i++)
{
int x,y;
cin >> x >> y;
x--;y--;
g[x].push_back(y);
g[y].push_back(x);
}
for(int i =0;i<200000;i++)
{
G[i] = 1e9;
}
priority_queue<P,vector<P>,greater<P>>PQ;
G[X] = 0.0;
PQ.emplace(0.0,X);
while(!PQ.empty())
{
auto now = PQ.top();
PQ.pop();
int v = now.second;
//cout<<v<<endl;
if(G[v]!=now.first)continue;
//cout<<v<<endl;
for(auto i: g[v])
{
double div = sqrt((vp[i].first-vp[v].first)*(vp[i].first-vp[v].first)+(vp[i].second-vp[v].second)*(vp[i].second-vp[v].second));
if(G[i]>G[v]+div)
{
G[i]=G[v]+div;
PQ.emplace(G[i],i);
}
}
}
printf("%.7lf\n",G[Y]);
}