結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー tko919tko919
提出日時 2020-05-29 22:32:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 384 ms / 2,000 ms
コード長 1,223 bytes
コンパイル時間 1,838 ms
コンパイル使用メモリ 172,280 KB
実行使用メモリ 22,000 KB
最終ジャッジ日時 2024-04-23 23:36:29
合計ジャッジ時間 9,687 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
8,456 KB
testcase_01 AC 4 ms
8,392 KB
testcase_02 AC 176 ms
15,104 KB
testcase_03 AC 241 ms
22,000 KB
testcase_04 AC 240 ms
21,740 KB
testcase_05 AC 193 ms
21,996 KB
testcase_06 AC 191 ms
21,836 KB
testcase_07 AC 67 ms
11,392 KB
testcase_08 AC 248 ms
20,520 KB
testcase_09 AC 25 ms
9,284 KB
testcase_10 AC 110 ms
13,568 KB
testcase_11 AC 76 ms
11,912 KB
testcase_12 AC 56 ms
11,828 KB
testcase_13 AC 175 ms
16,956 KB
testcase_14 AC 206 ms
18,352 KB
testcase_15 AC 235 ms
19,500 KB
testcase_16 AC 119 ms
15,040 KB
testcase_17 AC 266 ms
20,612 KB
testcase_18 AC 86 ms
13,208 KB
testcase_19 AC 240 ms
19,748 KB
testcase_20 AC 63 ms
11,264 KB
testcase_21 AC 105 ms
14,832 KB
testcase_22 AC 219 ms
19,056 KB
testcase_23 AC 6 ms
8,688 KB
testcase_24 AC 7 ms
8,960 KB
testcase_25 AC 51 ms
11,720 KB
testcase_26 AC 129 ms
14,992 KB
testcase_27 AC 132 ms
15,224 KB
testcase_28 AC 233 ms
19,952 KB
testcase_29 AC 32 ms
10,616 KB
testcase_30 AC 242 ms
20,568 KB
testcase_31 AC 166 ms
17,712 KB
testcase_32 AC 107 ms
14,064 KB
testcase_33 AC 231 ms
21,228 KB
testcase_34 AC 86 ms
13,148 KB
testcase_35 AC 237 ms
20,840 KB
testcase_36 AC 6 ms
8,576 KB
testcase_37 AC 8 ms
8,704 KB
testcase_38 AC 7 ms
8,576 KB
testcase_39 AC 7 ms
8,664 KB
testcase_40 AC 6 ms
8,448 KB
testcase_41 AC 384 ms
21,032 KB
testcase_42 AC 103 ms
12,160 KB
testcase_43 AC 186 ms
15,100 KB
testcase_44 AC 63 ms
10,788 KB
testcase_45 AC 178 ms
14,948 KB
testcase_46 AC 5 ms
8,432 KB
testcase_47 AC 4 ms
8,704 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:32:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
   32 |       auto [d,v]=pq.top(); pq.pop();
      |            ^
main.cpp:34:16: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
   34 |       for(auto [add,to]:g[v]){
      |                ^

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end

typedef pair<int,int> P;
typedef pair<double,int> P2;

vector<P2> g[201010];

int main(){
   int n,m; cin>>n>>m;
   int s,t; cin>>s>>t; s--; t--;
   vector<P> pos(n); rep(i,0,n)cin>>pos[i].first>>pos[i].second;
   rep(i,0,m){
      int x,y; cin>>x>>y; x--; y--;
      double d=hypot(pos[x].first-pos[y].first,pos[x].second-pos[y].second);
      g[x].push_back({d,y}); g[y].push_back({d,x});
   }
   vector<double> dist(n,inf);
   dist[s]=0;
   priority_queue<P2,vector<P2>,greater<P2>> pq; pq.push({0,s});
   while(!pq.empty()){
      auto [d,v]=pq.top(); pq.pop();
      if(dist[v]<d)continue;
      for(auto [add,to]:g[v]){
         if(chmin(dist[to],d+add)){
            pq.push({dist[to],to});
         }
      }
   }
   printf("%.12f\n",dist[t]);
   return 0;
}
0