結果
問題 |
No.1065 電柱 / Pole (Easy)
|
ユーザー |
![]() |
提出日時 | 2020-05-31 03:46:37 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,393 bytes |
コンパイル時間 | 3,770 ms |
コンパイル使用メモリ | 250,956 KB |
最終ジャッジ日時 | 2025-01-10 19:56:44 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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(make_pair(0,s)); 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(make_pair(d[v]*(-1),v)); } } } } 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(make_pair(b,c)); vec[b].push_back(make_pair(a,c)); } dijk(x); cout<< fixed << setprecision(15) <<d[y]<<endl; return 0; }