結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー otamay6otamay6
提出日時 2020-05-29 21:46:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 430 ms / 2,000 ms
コード長 1,172 bytes
コンパイル時間 2,238 ms
コンパイル使用メモリ 171,804 KB
実行使用メモリ 22,624 KB
最終ジャッジ日時 2024-04-23 21:10:49
合計ジャッジ時間 10,449 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 197 ms
13,440 KB
testcase_03 AC 268 ms
21,460 KB
testcase_04 AC 276 ms
21,332 KB
testcase_05 AC 216 ms
21,208 KB
testcase_06 AC 218 ms
21,160 KB
testcase_07 AC 76 ms
8,448 KB
testcase_08 AC 291 ms
21,760 KB
testcase_09 AC 27 ms
5,376 KB
testcase_10 AC 131 ms
11,520 KB
testcase_11 AC 89 ms
9,088 KB
testcase_12 AC 52 ms
7,168 KB
testcase_13 AC 187 ms
14,428 KB
testcase_14 AC 219 ms
16,828 KB
testcase_15 AC 258 ms
18,680 KB
testcase_16 AC 123 ms
11,552 KB
testcase_17 AC 279 ms
19,856 KB
testcase_18 AC 84 ms
9,088 KB
testcase_19 AC 269 ms
19,132 KB
testcase_20 AC 68 ms
7,808 KB
testcase_21 AC 106 ms
10,624 KB
testcase_22 AC 246 ms
17,656 KB
testcase_23 AC 4 ms
5,376 KB
testcase_24 AC 5 ms
5,376 KB
testcase_25 AC 45 ms
6,912 KB
testcase_26 AC 140 ms
12,452 KB
testcase_27 AC 144 ms
12,428 KB
testcase_28 AC 247 ms
18,232 KB
testcase_29 AC 27 ms
6,016 KB
testcase_30 AC 264 ms
19,748 KB
testcase_31 AC 188 ms
16,032 KB
testcase_32 AC 118 ms
11,316 KB
testcase_33 AC 254 ms
20,408 KB
testcase_34 AC 91 ms
9,344 KB
testcase_35 AC 271 ms
20,192 KB
testcase_36 AC 3 ms
5,376 KB
testcase_37 AC 4 ms
5,376 KB
testcase_38 AC 4 ms
5,376 KB
testcase_39 AC 5 ms
5,376 KB
testcase_40 AC 3 ms
5,376 KB
testcase_41 AC 430 ms
22,624 KB
testcase_42 AC 116 ms
9,472 KB
testcase_43 AC 212 ms
13,568 KB
testcase_44 AC 72 ms
7,168 KB
testcase_45 AC 198 ms
13,312 KB
testcase_46 AC 2 ms
5,376 KB
testcase_47 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int N,M;
    cin>>N>>M;
    int X,Y;
    cin>>X>>Y;
    X--;Y--;
    vector<double> p(N),q(N);
    REP(i,N) cin>>p[i]>>q[i];
    using P = pair<double,int> ;
    vector<vector<P>> graph(N);
    REP(i,M){
        int a,b; cin>>a>>b;
        a--;b--;
        double c = sqrt(pow(p[a]-p[b],2) + pow(q[a]-q[b],2));
        graph[a].push_back(P(c,b));
        graph[b].push_back(P(c,a));
    }
    vector<double> dist(N,1e9);
    priority_queue<P,vector<P>,greater<>> que;
    dist[X]=0;
    que.push(P(0,X));
    while(!que.empty()){
        P p=que.top();que.pop();
        int u=p.second;
        if(dist[u]<p.first) continue;
        REP(j,graph[u].size()){
            int v=graph[u][j].second;
            double alt=dist[u]+graph[u][j].first;
            if(dist[v]>alt){
                dist[v]=alt;
                que.push(P(alt,v));
            }
        }
    }
    printf("%.16f\n",dist[Y]);
}
0