結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー karinohitokarinohito
提出日時 2021-05-14 00:58:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 2,105 bytes
コンパイル時間 1,444 ms
コンパイル使用メモリ 116,740 KB
実行使用メモリ 814,188 KB
最終ジャッジ日時 2024-04-08 11:45:19
合計ジャッジ時間 8,139 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 179 ms
13,312 KB
testcase_03 AC 419 ms
37,840 KB
testcase_04 AC 375 ms
37,840 KB
testcase_05 MLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

//#include <atcoder/all>
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
//using namespace atcoder;
using ll = long long;
#define all(A) A.begin(),A.end()
using vll = vector<ll>;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using Graph = vector<vector<pair<ll,double>>>;

vector<pair<ll,ll>> Z;
double dist(ll A,ll B){
    ll dx=Z[A].first-Z[B].first;
    ll dy=Z[A].second-Z[B].second;
    return sqrt(dx*dx+dy*dy);
}


int main() {
    ll N,M,X,Y;
    cin >> N>>M>>X>>Y;
    X--;Y--;
    Graph G(N);
    Z.resize(N);
   
    rep(i,N){
        ll P,Q;
        cin>>P>>Q;
        Z[i]=make_pair(P,Q);
    }
    rep(m,M){
        ll P,Q;
        cin>>P>>Q;
        P--;Q--;
        G[P].push_back(make_pair(Q,dist(P,Q)));
        G[Q].push_back(make_pair(P,dist(P,Q)));
    }

    priority_queue<pair<double,ll>,vector<pair<double,ll>>,greater<pair<double,ll>>> que;
    vector<double> D(N,1e18);

    que.push(make_pair(double(0),X));
    D[X]=0;

    while(!que.empty()){
        auto p=que.top();
        que.pop();
        ll v=p.second;

        for(auto next:G[v]){
            ll nv=next.first;
            double d=next.second;

            if(D[nv]<D[v]+d)continue;

            else{
                //cout<<"k";
                D[nv]=D[v]+d;
                que.push(make_pair(D[nv],nv));
            }

        }
    }

    cout<<setprecision(16);
    cout<<D[Y]<<endl;


    

}
0