結果
問題 | No.1065 電柱 / Pole (Easy) |
ユーザー |
![]() |
提出日時 | 2020-04-20 19:44:01 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 2,103 bytes |
コンパイル時間 | 2,753 ms |
コンパイル使用メモリ | 222,256 KB |
実行使用メモリ | 814,112 KB |
最終ジャッジ日時 | 2024-10-01 23:16:17 |
合計ジャッジ時間 | 6,606 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | AC | 192 ms
21,012 KB |
testcase_03 | MLE | - |
testcase_04 | -- | - |
testcase_05 | -- | - |
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 | -- | - |
ソースコード
/* 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); for(lint k=0;k<(lint)que.size();k++){ lint x=que.at(k); ckd.at(x)=true; for(auto[y,_]:g.at(x)){ if(ckd.at(y))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<<dist.at(t)<<'\n'; }