結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー tkmst201tkmst201
提出日時 2021-02-17 15:56:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 236 ms / 2,000 ms
コード長 1,303 bytes
コンパイル時間 2,722 ms
コンパイル使用メモリ 211,748 KB
実行使用メモリ 20,972 KB
最終ジャッジ日時 2023-10-12 02:59:44
合計ジャッジ時間 13,043 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 98 ms
12,224 KB
testcase_03 AC 126 ms
20,924 KB
testcase_04 AC 126 ms
20,972 KB
testcase_05 AC 96 ms
20,556 KB
testcase_06 AC 95 ms
20,832 KB
testcase_07 AC 30 ms
7,724 KB
testcase_08 AC 110 ms
20,180 KB
testcase_09 AC 11 ms
4,692 KB
testcase_10 AC 49 ms
10,900 KB
testcase_11 AC 34 ms
8,156 KB
testcase_12 AC 25 ms
6,928 KB
testcase_13 AC 103 ms
13,768 KB
testcase_14 AC 120 ms
15,656 KB
testcase_15 AC 139 ms
17,396 KB
testcase_16 AC 66 ms
11,048 KB
testcase_17 AC 158 ms
18,448 KB
testcase_18 AC 46 ms
8,824 KB
testcase_19 AC 146 ms
17,704 KB
testcase_20 AC 33 ms
7,132 KB
testcase_21 AC 57 ms
10,316 KB
testcase_22 AC 132 ms
16,376 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 3 ms
4,348 KB
testcase_25 AC 23 ms
6,624 KB
testcase_26 AC 74 ms
11,576 KB
testcase_27 AC 79 ms
11,476 KB
testcase_28 AC 141 ms
17,176 KB
testcase_29 AC 15 ms
5,692 KB
testcase_30 AC 146 ms
18,796 KB
testcase_31 AC 96 ms
15,156 KB
testcase_32 AC 59 ms
10,424 KB
testcase_33 AC 142 ms
20,360 KB
testcase_34 AC 48 ms
8,932 KB
testcase_35 AC 146 ms
18,792 KB
testcase_36 AC 2 ms
4,348 KB
testcase_37 AC 3 ms
4,352 KB
testcase_38 AC 3 ms
4,348 KB
testcase_39 AC 3 ms
4,348 KB
testcase_40 AC 2 ms
4,352 KB
testcase_41 AC 236 ms
20,784 KB
testcase_42 AC 53 ms
8,648 KB
testcase_43 AC 105 ms
12,348 KB
testcase_44 AC 30 ms
6,620 KB
testcase_45 AC 106 ms
12,072 KB
testcase_46 AC 1 ms
4,352 KB
testcase_47 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = false;
//---------------------------------//

int main() {
	int N, M, X, Y;
	cin >> N >> M >> X >> Y;
	--X; --Y;
	vector<int> y(N), x(N);
	REP(i, N) scanf("%d %d", &y[i], &x[i]);
	vector<vector<pair<int, double>>> g(N);
	REP(i, M) {
		int P, Q;
		scanf("%d %d", &P, &Q);
		--P; --Q;
		const double l = hypot(x[P] - x[Q], y[P] - y[Q]);
		g[P].emplace_back(Q, l);
		g[Q].emplace_back(P, l);
	}
	
	using tup = tuple<double, int>;
	vector<double> dist(N, INF);
	priority_queue<tup, vector<tup>, greater<tup>> pq;
	dist[X] = 0;
	pq.emplace(0, X);
	while (!pq.empty()) {
		auto [d, u] = pq.top(); pq.pop();
		if (dist[u] != d) continue;
		for (auto [v, c] : g[u]) if (chmin(dist[v], d + c)) pq.emplace(dist[v], v);
	}
	printf("%.18f\n", dist[Y]);
}
0