結果
| 問題 |
No.1065 電柱 / Pole (Easy)
|
| コンテスト | |
| ユーザー |
tko919
|
| 提出日時 | 2020-05-29 22:32:54 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 372 ms / 2,000 ms |
| コード長 | 1,223 bytes |
| コンパイル時間 | 1,737 ms |
| コンパイル使用メモリ | 175,932 KB |
| 実行使用メモリ | 23,188 KB |
| 最終ジャッジ日時 | 2024-11-06 06:00:06 |
| 合計ジャッジ時間 | 9,411 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 46 |
コンパイルメッセージ
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]){
| ^
ソースコード
#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;
}
tko919