結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー ngtkanangtkana
提出日時 2020-04-20 19:48:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,141 bytes
コンパイル時間 2,566 ms
コンパイル使用メモリ 215,804 KB
実行使用メモリ 38,508 KB
最終ジャッジ日時 2024-04-09 22:44:25
合計ジャッジ時間 9,823 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
6,944 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 213 ms
38,224 KB
testcase_05 AC 166 ms
36,640 KB
testcase_06 AC 166 ms
37,776 KB
testcase_07 AC 52 ms
12,240 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 85 ms
18,132 KB
testcase_11 AC 60 ms
13,356 KB
testcase_12 AC 44 ms
10,880 KB
testcase_13 WA -
testcase_14 AC 193 ms
30,364 KB
testcase_15 AC 229 ms
32,600 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 241 ms
34,028 KB
testcase_20 WA -
testcase_21 AC 91 ms
16,936 KB
testcase_22 AC 214 ms
30,044 KB
testcase_23 AC 4 ms
6,940 KB
testcase_24 AC 4 ms
6,944 KB
testcase_25 WA -
testcase_26 AC 119 ms
20,464 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 91 ms
18,096 KB
testcase_33 WA -
testcase_34 AC 79 ms
14,584 KB
testcase_35 AC 244 ms
34,872 KB
testcase_36 AC 3 ms
6,940 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 4 ms
6,944 KB
testcase_40 AC 2 ms
6,940 KB
testcase_41 AC 378 ms
37,124 KB
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 51 ms
10,300 KB
testcase_45 WA -
testcase_46 AC 2 ms
6,940 KB
testcase_47 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

/* validator */

#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>;

int main(){
    auto read=[]{
        std::string s;std::getline(std::cin,s);
        lint n=s.length();
        lint l=0,r;
        for(r=l;r<n&&s.at(r)!=' ';r++);
        assert(r-l<=9);
        lint x=std::stoll(s.substr(l,r-l));
        l=r+1;
        for(r=l;r<n&&s.at(r)!=' ';r++);
        assert(r-l<=9);
        lint y=std::stoll(s.substr(l,r-l));
        return std::pair{x,y};
    };
    auto[n,m]=read();
    assert(2<=n&&n<=200'000&&n-1<=m&&m<=std::min(n*(n-1)/2,200'000ll));
    auto[s,t]=read();
    assert(1<=s&&s<=n&&1<=t&&t<=n);
    s--,t--;
    std::vector<std::pair<ld,ld>>pt(n);
    for(lint i=0;i<n;i++){
        auto[x,y]=read();
        assert(-1'000<=x&&x<=1'000&&-1'000<=y&&y<=1'000);
        pt.at(i)={x,y};
    }
    std::vector<std::vector<std::pair<lint,ld>>>g(n);
    for(lint i=0;i<m;i++){
        auto[u,v]=read();
        assert(1<=u&&u<=n&&1<=v&&v<=n);
        u--,v--;
        ld w=std::hypot(pt.at(u).first-pt.at(v).first,pt.at(u).second-pt.at(v).second);
        g.at(u).emplace_back(v,w);
        g.at(v).emplace_back(u,w);
    }
    std::vector<lint>que,ckd(n);
    que.push_back(s);
    ckd.at(s)=true;
    for(lint k=0;k<(lint)que.size();k++){
        lint x=que.at(k);
        for(auto[y,_]:g.at(x)){
            if(std::exchange(ckd.at(y),true))continue;
            que.push_back(y);
        }
    }
    assert(ckd.at(t));
    assert(!std::cin.eof());
    std::string emplyline;std::getline(std::cin,emplyline);
    assert(std::cin.eof());

    ld inf=numr<ld>::infinity();
    std::vector<ld>dist(n,inf);
    std::priority_queue<std::pair<ld,lint>>pque;
    dist.at(s)=0;
    pque.emplace(0,s);
    while(!pque.empty()){
        lint x;std::tie(std::ignore,x)=pque.top();pque.pop();
        for(auto[y,w]:g.at(x)){
            ld d=dist.at(x)+w;
            if(dist.at(y)<=d)continue;
            dist.at(y)=d;
            pque.emplace(-d,y);
        }
    }
    std::cout<<std::setprecision(4)<<dist.at(t)<<'\n';
}
0