結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー oriekaorieka
提出日時 2020-05-30 10:12:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 323 ms / 2,000 ms
コード長 1,065 bytes
コンパイル時間 1,240 ms
コンパイル使用メモリ 110,656 KB
実行使用メモリ 17,408 KB
最終ジャッジ日時 2024-04-24 20:08:16
合計ジャッジ時間 8,169 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 141 ms
10,368 KB
testcase_03 AC 194 ms
13,860 KB
testcase_04 AC 194 ms
13,860 KB
testcase_05 AC 169 ms
13,728 KB
testcase_06 AC 168 ms
13,988 KB
testcase_07 AC 62 ms
7,296 KB
testcase_08 AC 242 ms
17,280 KB
testcase_09 AC 22 ms
5,376 KB
testcase_10 AC 104 ms
9,472 KB
testcase_11 AC 71 ms
7,808 KB
testcase_12 AC 46 ms
5,376 KB
testcase_13 AC 151 ms
9,344 KB
testcase_14 AC 159 ms
11,264 KB
testcase_15 AC 191 ms
12,672 KB
testcase_16 AC 99 ms
6,784 KB
testcase_17 AC 212 ms
13,184 KB
testcase_18 AC 71 ms
5,760 KB
testcase_19 AC 198 ms
13,312 KB
testcase_20 AC 52 ms
6,272 KB
testcase_21 AC 89 ms
6,208 KB
testcase_22 AC 176 ms
12,032 KB
testcase_23 AC 4 ms
5,376 KB
testcase_24 AC 4 ms
5,376 KB
testcase_25 AC 40 ms
5,376 KB
testcase_26 AC 103 ms
8,576 KB
testcase_27 AC 109 ms
7,808 KB
testcase_28 AC 181 ms
10,624 KB
testcase_29 AC 25 ms
5,376 KB
testcase_30 AC 190 ms
13,208 KB
testcase_31 AC 123 ms
10,560 KB
testcase_32 AC 82 ms
8,064 KB
testcase_33 AC 173 ms
13,312 KB
testcase_34 AC 72 ms
6,016 KB
testcase_35 AC 191 ms
12,688 KB
testcase_36 AC 3 ms
5,376 KB
testcase_37 AC 3 ms
5,376 KB
testcase_38 AC 3 ms
5,376 KB
testcase_39 AC 4 ms
5,376 KB
testcase_40 AC 2 ms
5,376 KB
testcase_41 AC 323 ms
17,408 KB
testcase_42 AC 85 ms
7,680 KB
testcase_43 AC 149 ms
10,752 KB
testcase_44 AC 50 ms
6,144 KB
testcase_45 AC 148 ms
10,624 KB
testcase_46 AC 2 ms
5,376 KB
testcase_47 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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