結果
問題 | No.1065 電柱 / Pole (Easy) |
ユーザー |
![]() |
提出日時 | 2020-05-29 22:08:01 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 217 ms / 2,000 ms |
コード長 | 1,360 bytes |
コンパイル時間 | 2,684 ms |
コンパイル使用メモリ | 188,188 KB |
実行使用メモリ | 22,128 KB |
最終ジャッジ日時 | 2024-11-14 22:35:57 |
合計ジャッジ時間 | 8,008 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 46 |
ソースコード
#pragma GCC optimize ("O3") #pragma GCC target ("avx2") #include<bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for(int i = 0; i < (n); i++) #define rep1(i, n) for(int i = 1; i <= (n); i++) #define co(x) cout << (x) << "\n" #define cosp(x) cout << (x) << " " #define ce(x) cerr << (x) << "\n" #define cesp(x) cerr << (x) << " " #define pb push_back #define mp make_pair #define chmin(x, y) x = min(x, y) #define chmax(x, y) x = max(x, y) #define Would #define you #define please #define PT pair<double, int> int main() { cin.tie(0); ios::sync_with_stdio(false); int N, M, X, Y; cin >> N >> M >> X >> Y; int P[200001], Q[200001]; rep1(i, N) { cin >> P[i] >> Q[i]; } vector<PT> E[200001]; rep1(i, M) { int p, q; cin >> p >> q; int x = (P[p] - P[q]); int y = (Q[p] - Q[q]); double d = sqrt(x * x + y * y); E[p].pb({ d, q }); E[q].pb({ d, p }); } double D[200001]; rep1(i, N) D[i] = 1e18; D[X] = 0; priority_queue<PT, vector<PT>, greater<PT>> que; que.push(mp(0, X)); while (que.size()) { PT p = que.top(); que.pop(); int i = p.second; if (D[i] != p.first) continue; for (PT p2 : E[i]) { int j = p2.second; double d = D[i] + p2.first; if (D[j] > d) { D[j] = d; que.push(mp(d, j)); } } } cout << setprecision(12) << D[Y] << endl; Would you please return 0; }