結果
問題 |
No.1065 電柱 / Pole (Easy)
|
ユーザー |
|
提出日時 | 2020-05-30 10:12:26 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 357 ms / 2,000 ms |
コード長 | 1,065 bytes |
コンパイル時間 | 1,947 ms |
コンパイル使用メモリ | 108,312 KB |
最終ジャッジ日時 | 2025-01-10 19:14:39 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 46 |
ソースコード
#include <iostream> #include <vector> #include <climits> #include <algorithm> #include <cmath> #include <map> #include <set> #include <string> #include <bitset> #include <utility> #include <numeric> #include <queue> #include <stack> using ll = long long; using namespace std; constexpr int MOD = 1e9 + 7; constexpr ll MOD_LL = ll(1e9) + 7; int main(void) { int n, m, x, y; cin >> n >> m >> x >> y; x--; y--; vector<int> p(n), q(n); for(int i = 0; i < n; ++i) { cin >> p[i] >> q[i]; } vector< vector<int> > G(n); for(int i = 0; i < m; ++i) { int a, b; cin >> a >> b; a--; b--; G[a].push_back(b); G[b].push_back(a); } vector<double> dist(n, 1e9 + 10); dist[x] = 0.0; queue<int> que; que.push(x); while( !que.empty() ) { int now = que.front(); que.pop(); for(auto &to : G[now]) { double cost = dist[now] + sqrt((p[now] - p[to]) * (p[now] - p[to]) + (q[now] - q[to]) * (q[now] - q[to])); if( dist[to] > cost ) { dist[to] = cost; que.push(to); } } } printf("%.12f\n", dist[y]); return 0; }