結果
| 問題 | 
                            No.1065 電柱 / Pole (Easy)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             Re_code_A
                         | 
                    
| 提出日時 | 2020-05-29 21:53:22 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 409 ms / 2,000 ms | 
| コード長 | 1,414 bytes | 
| コンパイル時間 | 1,981 ms | 
| コンパイル使用メモリ | 185,976 KB | 
| 実行使用メモリ | 34,244 KB | 
| 最終ジャッジ日時 | 2024-11-06 04:06:42 | 
| 合計ジャッジ時間 | 10,384 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 46 | 
ソースコード
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
int main(){
    cout<<fixed<<setprecision(20);
    int n,m; cin>>n>>m;
    int x,y; cin>>x>>y;
    x--; y--;
    vector<pp> pos(n);
    vector<vector<pair<int,ld>>> path(n);
    rep(i,n){
        int p,q; cin>>p>>q;
        pos[i]=mk(p,q);
    }
    rep(i,m){
        int p,q; cin>>p>>q;
        p--; q--;
        ld dis=0;
        dis+=(pos[p].first-pos[q].first)*(pos[p].first-pos[q].first);
        dis+=(pos[p].second-pos[q].second)*(pos[p].second-pos[q].second);
        dis=sqrt(dis);
        path[p].push_back(mk(q,dis));
        path[q].push_back(mk(p,dis));
    }
    vector<ld> d(n,inf);
    d[x]=0;
    priority_queue<pair<ld,int>, vector<pair<ld,int>>, greater<pair<ld,int>>> pq;
    pq.push(mk(0.0,x)); //cost,s #
    int s,to;
    ld cost,w;
    while(!(pq.empty())){
        tie(cost,s)=pq.top(); pq.pop();
        if(d[s]!=cost) continue;
        for(auto p:path[s]){
            tie(to,w)=p; //#
            if(d[to]>d[s]+w){
                d[to]=d[s]+w;
                pq.push(mk(d[to],to));
            }
        }
    }
    cout<<d[y]<<endl;
}
            
            
            
        
            
Re_code_A