結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー uzzyuzzy
提出日時 2020-05-29 22:08:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 200 ms / 2,000 ms
コード長 1,360 bytes
コンパイル時間 2,522 ms
コンパイル使用メモリ 186,704 KB
実行使用メモリ 24,720 KB
最終ジャッジ日時 2024-04-27 03:13:56
合計ジャッジ時間 7,198 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
9,960 KB
testcase_01 AC 4 ms
11,232 KB
testcase_02 AC 79 ms
15,956 KB
testcase_03 AC 112 ms
23,168 KB
testcase_04 AC 115 ms
22,864 KB
testcase_05 AC 91 ms
22,776 KB
testcase_06 AC 92 ms
24,720 KB
testcase_07 AC 28 ms
13,056 KB
testcase_08 AC 101 ms
20,584 KB
testcase_09 AC 13 ms
11,248 KB
testcase_10 AC 46 ms
14,996 KB
testcase_11 AC 32 ms
14,164 KB
testcase_12 AC 24 ms
14,036 KB
testcase_13 AC 80 ms
18,232 KB
testcase_14 AC 101 ms
19,032 KB
testcase_15 AC 127 ms
20,492 KB
testcase_16 AC 60 ms
16,216 KB
testcase_17 AC 136 ms
21,112 KB
testcase_18 AC 41 ms
14,540 KB
testcase_19 AC 124 ms
20,184 KB
testcase_20 AC 33 ms
12,796 KB
testcase_21 AC 48 ms
16,348 KB
testcase_22 AC 110 ms
19,544 KB
testcase_23 AC 5 ms
11,364 KB
testcase_24 AC 5 ms
10,352 KB
testcase_25 AC 23 ms
14,056 KB
testcase_26 AC 61 ms
16,132 KB
testcase_27 AC 63 ms
16,948 KB
testcase_28 AC 116 ms
20,700 KB
testcase_29 AC 16 ms
11,648 KB
testcase_30 AC 124 ms
21,148 KB
testcase_31 AC 82 ms
18,312 KB
testcase_32 AC 54 ms
15,760 KB
testcase_33 AC 119 ms
22,424 KB
testcase_34 AC 43 ms
15,428 KB
testcase_35 AC 120 ms
21,388 KB
testcase_36 AC 5 ms
11,112 KB
testcase_37 AC 5 ms
10,100 KB
testcase_38 AC 4 ms
10,096 KB
testcase_39 AC 5 ms
9,976 KB
testcase_40 AC 4 ms
9,964 KB
testcase_41 AC 200 ms
21,404 KB
testcase_42 AC 46 ms
13,248 KB
testcase_43 AC 82 ms
15,884 KB
testcase_44 AC 29 ms
12,304 KB
testcase_45 AC 85 ms
15,872 KB
testcase_46 AC 4 ms
9,828 KB
testcase_47 AC 4 ms
10,632 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0