結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー m1025o1184tm1025o1184t
提出日時 2020-05-29 21:56:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 245 ms / 2,000 ms
コード長 1,336 bytes
コンパイル時間 2,667 ms
コンパイル使用メモリ 174,132 KB
実行使用メモリ 22,788 KB
最終ジャッジ日時 2024-04-23 21:57:03
合計ジャッジ時間 7,011 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
8,564 KB
testcase_01 AC 5 ms
8,904 KB
testcase_02 AC 109 ms
15,476 KB
testcase_03 AC 124 ms
22,036 KB
testcase_04 AC 124 ms
22,788 KB
testcase_05 AC 91 ms
21,820 KB
testcase_06 AC 90 ms
21,536 KB
testcase_07 AC 31 ms
11,780 KB
testcase_08 AC 102 ms
20,416 KB
testcase_09 AC 12 ms
9,440 KB
testcase_10 AC 48 ms
14,404 KB
testcase_11 AC 35 ms
12,356 KB
testcase_12 AC 26 ms
12,356 KB
testcase_13 AC 107 ms
16,940 KB
testcase_14 AC 124 ms
19,028 KB
testcase_15 AC 148 ms
19,516 KB
testcase_16 AC 68 ms
15,900 KB
testcase_17 AC 162 ms
20,976 KB
testcase_18 AC 48 ms
12,876 KB
testcase_19 AC 150 ms
20,192 KB
testcase_20 AC 38 ms
11,660 KB
testcase_21 AC 60 ms
15,872 KB
testcase_22 AC 132 ms
18,984 KB
testcase_23 AC 5 ms
9,028 KB
testcase_24 AC 6 ms
8,772 KB
testcase_25 AC 23 ms
12,356 KB
testcase_26 AC 77 ms
15,768 KB
testcase_27 AC 76 ms
15,872 KB
testcase_28 AC 145 ms
20,456 KB
testcase_29 AC 16 ms
10,708 KB
testcase_30 AC 149 ms
20,452 KB
testcase_31 AC 103 ms
17,468 KB
testcase_32 AC 66 ms
13,948 KB
testcase_33 AC 149 ms
22,376 KB
testcase_34 AC 50 ms
12,796 KB
testcase_35 AC 145 ms
20,716 KB
testcase_36 AC 4 ms
8,516 KB
testcase_37 AC 6 ms
9,412 KB
testcase_38 AC 5 ms
8,644 KB
testcase_39 AC 6 ms
8,520 KB
testcase_40 AC 5 ms
9,156 KB
testcase_41 AC 245 ms
21,184 KB
testcase_42 AC 57 ms
12,248 KB
testcase_43 AC 111 ms
15,680 KB
testcase_44 AC 36 ms
10,612 KB
testcase_45 AC 108 ms
14,924 KB
testcase_46 AC 4 ms
8,340 KB
testcase_47 AC 4 ms
9,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<double, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

struct edge { int to; double cost; };
vector<edge> g[200005];
int n, m;
int X, Y;
double d[200005];

double dijkstra() {
	priority_queue<P, vector<P>, greater<P>> pq;
	fill(d, d + n, inf);
	d[X] = 0;
	pq.emplace(0, X);
	while (pq.size()) {
		P p = pq.top(); pq.pop();
		int v = p.second;
		if (d[v] < p.first) continue;
		for (auto& c : g[v]) {
			edge e = c;
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				pq.emplace(d[e.to], e.to);
			}
		}
	}
	return d[Y];
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m;
	cin >> X >> Y;
	X--; Y--;
	vector<int> p(n), q(n);
	rep(i, n) cin >> p[i] >> q[i];
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back({ b, sqrt(pow(abs(p[a] - p[b]), 2) + pow(abs(q[a] - q[b]), 2)) });
		g[b].push_back({ a, sqrt(pow(abs(p[a] - p[b]), 2) + pow(abs(q[a] - q[b]), 2)) });
	}
	double ans = dijkstra();
	printf("%.10f\n", ans);
 	return 0;
}
0