結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー ngtkanangtkana
提出日時 2020-04-20 21:22:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 224 ms / 2,000 ms
コード長 1,195 bytes
コンパイル時間 2,287 ms
コンパイル使用メモリ 209,680 KB
実行使用メモリ 35,020 KB
最終ジャッジ日時 2024-04-09 22:42:52
合計ジャッジ時間 7,580 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 97 ms
17,664 KB
testcase_03 AC 154 ms
33,000 KB
testcase_04 AC 152 ms
33,320 KB
testcase_05 AC 117 ms
35,020 KB
testcase_06 AC 119 ms
34,960 KB
testcase_07 AC 32 ms
10,496 KB
testcase_08 AC 115 ms
29,668 KB
testcase_09 AC 10 ms
6,944 KB
testcase_10 AC 49 ms
15,104 KB
testcase_11 AC 34 ms
11,520 KB
testcase_12 AC 27 ms
11,008 KB
testcase_13 AC 113 ms
21,408 KB
testcase_14 AC 130 ms
24,892 KB
testcase_15 AC 152 ms
28,488 KB
testcase_16 AC 71 ms
17,176 KB
testcase_17 AC 165 ms
29,496 KB
testcase_18 AC 49 ms
13,592 KB
testcase_19 AC 147 ms
28,052 KB
testcase_20 AC 35 ms
10,060 KB
testcase_21 AC 61 ms
16,460 KB
testcase_22 AC 139 ms
26,372 KB
testcase_23 AC 3 ms
6,940 KB
testcase_24 AC 3 ms
6,944 KB
testcase_25 AC 22 ms
10,624 KB
testcase_26 AC 77 ms
18,056 KB
testcase_27 AC 78 ms
17,884 KB
testcase_28 AC 143 ms
27,800 KB
testcase_29 AC 17 ms
8,192 KB
testcase_30 AC 164 ms
30,780 KB
testcase_31 AC 96 ms
25,468 KB
testcase_32 AC 62 ms
15,540 KB
testcase_33 AC 146 ms
30,756 KB
testcase_34 AC 51 ms
13,448 KB
testcase_35 AC 153 ms
30,796 KB
testcase_36 AC 3 ms
6,940 KB
testcase_37 AC 3 ms
6,940 KB
testcase_38 AC 3 ms
6,940 KB
testcase_39 AC 3 ms
6,940 KB
testcase_40 AC 2 ms
6,944 KB
testcase_41 AC 224 ms
30,952 KB
testcase_42 AC 56 ms
12,160 KB
testcase_43 AC 103 ms
18,176 KB
testcase_44 AC 33 ms
8,832 KB
testcase_45 AC 100 ms
17,816 KB
testcase_46 AC 2 ms
6,944 KB
testcase_47 AC 1 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using ld=long double;
template<class T>using numr=std::numeric_limits<T>;
auto cmn=[](auto&x,auto y){if(x>y)x=y;};
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n,m;std::cin>>n>>m;
    lint s,t;std::cin>>s>>t;s--,t--;
    std::vector<std::pair<lint,lint>>pt(n);
    for(auto&&p:pt)std::cin>>p.first>>p.second;
    std::vector<std::vector<std::pair<lint,ld>>>g(n);
    while(m--){
         lint u,v;std::cin>>u>>v;u--,v--;
         ld w=std::hypot(pt[u].first-pt[v].first,pt[u].second-pt[v].second);
         g[u].emplace_back(v,w);
         g[v].emplace_back(u,w);
    }
    ld inf=numr<ld>::infinity();
    std::vector<ld>dist(n,inf);
    std::priority_queue<std::pair<ld,lint>>que;
    dist[s]=0;
    que.emplace(0,s);
    while(!que.empty()){
        lint x;std::tie(std::ignore,x)=que.top();que.pop();
        for(auto[y,w]:g[x]){
            ld d=dist[x]+w;
            if(dist[y]<=d)continue;
            dist[y]=d;
            que.emplace(-d,y);
        }
    }
    std::cout<<dist[t]<<'\n';
}

0