結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 75 ms
12,672 KB
testcase_03 AC 118 ms
21,032 KB
testcase_04 AC 115 ms
21,132 KB
testcase_05 AC 87 ms
20,776 KB
testcase_06 AC 85 ms
20,624 KB
testcase_07 AC 26 ms
8,064 KB
testcase_08 AC 99 ms
20,408 KB
testcase_09 AC 10 ms
6,940 KB
testcase_10 AC 45 ms
11,008 KB
testcase_11 AC 30 ms
8,576 KB
testcase_12 AC 21 ms
7,296 KB
testcase_13 AC 78 ms
14,032 KB
testcase_14 AC 92 ms
15,892 KB
testcase_15 AC 110 ms
17,536 KB
testcase_16 AC 52 ms
11,092 KB
testcase_17 AC 119 ms
18,668 KB
testcase_18 AC 39 ms
8,912 KB
testcase_19 AC 113 ms
18,032 KB
testcase_20 AC 28 ms
7,680 KB
testcase_21 AC 46 ms
10,484 KB
testcase_22 AC 103 ms
16,648 KB
testcase_23 AC 3 ms
6,940 KB
testcase_24 AC 3 ms
6,940 KB
testcase_25 AC 19 ms
7,168 KB
testcase_26 AC 55 ms
11,836 KB
testcase_27 AC 63 ms
11,908 KB
testcase_28 AC 106 ms
17,180 KB
testcase_29 AC 14 ms
6,944 KB
testcase_30 AC 110 ms
18,572 KB
testcase_31 AC 79 ms
15,072 KB
testcase_32 AC 48 ms
10,740 KB
testcase_33 AC 114 ms
19,756 KB
testcase_34 AC 41 ms
9,144 KB
testcase_35 AC 123 ms
18,908 KB
testcase_36 AC 2 ms
6,940 KB
testcase_37 AC 2 ms
6,944 KB
testcase_38 AC 2 ms
6,940 KB
testcase_39 AC 3 ms
6,940 KB
testcase_40 AC 2 ms
6,944 KB
testcase_41 AC 198 ms
21,056 KB
testcase_42 AC 44 ms
9,088 KB
testcase_43 AC 85 ms
12,800 KB
testcase_44 AC 28 ms
7,040 KB
testcase_45 AC 80 ms
12,544 KB
testcase_46 AC 2 ms
6,940 KB
testcase_47 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
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);
    int n,m;std::cin>>n>>m;
    int s,t;std::cin>>s>>t;s--,t--;
    std::vector<std::pair<int,int>>pt(n);
    for(auto&&p:pt)std::cin>>p.first>>p.second;
    std::vector<std::vector<std::pair<int,double>>>g(n);
    while(m--){
         int u,v;std::cin>>u>>v;u--,v--;
         double 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);
    }
    double inf=numr<double>::infinity();
    std::vector<double>dist(n,inf);
    std::priority_queue<std::pair<double,int>>que;
    dist[s]=0;
    que.emplace(0,s);
    while(!que.empty()){
        int x;std::tie(std::ignore,x)=que.top();que.pop();
        for(auto[y,w]:g[x]){
            double d=dist[x]+w;
            if(dist[y]<=d)continue;
            dist[y]=d;
            que.emplace(-d,y);
        }
    }
    std::cout<<dist[t]<<'\n';
}

0