結果
| 問題 | No.1065 電柱 / Pole (Easy) |
| コンテスト | |
| ユーザー |
umezo
|
| 提出日時 | 2020-05-31 03:09:07 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,386 bytes |
| 記録 | |
| コンパイル時間 | 7,597 ms |
| コンパイル使用メモリ | 248,252 KB |
| 最終ジャッジ日時 | 2025-01-10 19:53:01 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 16 TLE * 30 |
ソースコード
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
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; }
#include <bits/stdc++.h>
using namespace std;
#define MAX 200010
#define INF 1000100100
vector<pair<int,double>> vec[MAX];
double d[MAX],color[MAX],p[MAX],q[MAX];
int n,m,x,y;
void dijk(int s){
priority_queue<pair<double,int>> pq;
for(int i=1;i<=n;i++){
d[i]=INF;
color[i]=0;
}
d[s]=0;
pq.push({0,s});
color[s]=1;
while(!pq.empty()){
pair<double,int> f=pq.top(); pq.pop();
int u=f.second;
color[u]=2;
if(d[u]<f.first*(-1)) continue;
for(int j=0;j<vec[u].size();j++){
int v=vec[u][j].first;
if(color[v]==2) continue;
if(d[v] > d[u]+vec[u][j].second){
d[v]=d[u]+vec[u][j].second;
pq.push({d[v]*(-1),v});
color[v]=1;
}
}
}
}
int main() {
cin>>n>>m>>x>>y;
int a,b;
double c;
rep(i,n) cin>>p[i+1]>>q[i+1];
rep(i,m){
cin>>a>>b;
c=sqrt((p[a]-p[b])*(p[a]-p[b])+(q[a]-q[b])*(q[a]-q[b]));
vec[a].push_back({b,c});
vec[b].push_back({a,c});
}
dijk(x);
cout<< fixed << setprecision(15) <<d[y]<<endl;
return 0;
}
umezo