結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー akun0716akun0716
提出日時 2020-05-29 21:46:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 437 ms / 2,000 ms
コード長 2,103 bytes
コンパイル時間 1,052 ms
コンパイル使用メモリ 96,776 KB
実行使用メモリ 34,048 KB
最終ジャッジ日時 2024-04-23 21:10:05
合計ジャッジ時間 9,873 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 203 ms
19,200 KB
testcase_03 AC 262 ms
34,008 KB
testcase_04 AC 264 ms
33,620 KB
testcase_05 AC 222 ms
33,624 KB
testcase_06 AC 221 ms
33,496 KB
testcase_07 AC 61 ms
11,392 KB
testcase_08 AC 230 ms
32,640 KB
testcase_09 AC 21 ms
6,144 KB
testcase_10 AC 102 ms
16,512 KB
testcase_11 AC 70 ms
12,544 KB
testcase_12 AC 63 ms
10,880 KB
testcase_13 AC 226 ms
22,632 KB
testcase_14 AC 259 ms
26,300 KB
testcase_15 AC 296 ms
29,020 KB
testcase_16 AC 152 ms
17,808 KB
testcase_17 AC 323 ms
31,280 KB
testcase_18 AC 101 ms
14,036 KB
testcase_19 AC 301 ms
29,608 KB
testcase_20 AC 76 ms
10,556 KB
testcase_21 AC 133 ms
16,848 KB
testcase_22 AC 280 ms
27,652 KB
testcase_23 AC 5 ms
5,376 KB
testcase_24 AC 5 ms
5,376 KB
testcase_25 AC 56 ms
10,496 KB
testcase_26 AC 162 ms
19,216 KB
testcase_27 AC 171 ms
18,848 KB
testcase_28 AC 312 ms
29,164 KB
testcase_29 AC 35 ms
8,192 KB
testcase_30 AC 307 ms
31,996 KB
testcase_31 AC 205 ms
25,020 KB
testcase_32 AC 133 ms
16,620 KB
testcase_33 AC 294 ms
32,352 KB
testcase_34 AC 110 ms
13,944 KB
testcase_35 AC 308 ms
32,048 KB
testcase_36 AC 3 ms
5,376 KB
testcase_37 AC 5 ms
5,376 KB
testcase_38 AC 4 ms
5,376 KB
testcase_39 AC 5 ms
5,376 KB
testcase_40 AC 3 ms
5,376 KB
testcase_41 AC 437 ms
34,048 KB
testcase_42 AC 117 ms
13,056 KB
testcase_43 AC 210 ms
19,840 KB
testcase_44 AC 68 ms
9,472 KB
testcase_45 AC 206 ms
19,456 KB
testcase_46 AC 2 ms
5,376 KB
testcase_47 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define ld long double
typedef vector<ld> VI;
typedef pair<ld, ld> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 922337203685477807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;

int N, M;
int X, Y;
struct edge { 
	int to;
	ld cost;
};

vector<vector<edge> > G;
VI d;

void dikstra(int s) {
	priority_queue<pii, vector<pii>, greater<pii> >que;
	REP(i, N)d[i] = LLINF;
	d[s] = 0;
	que.push(pii(0, s));
	while (!que.empty()) {
		pii p = que.top();
		que.pop();
		int v = p.second;
		if (d[v] < p.first)continue;
		REP(i, G[v].size()) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(pii(d[e.to], e.to));
			}
		}
	}
}

ld dd(pii a, pii b) {
	return pow((a.first - b.first)*(a.first - b.first) + (a.second - b.second)*(a.second - b.second),0.5);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N >> M;
	G.resize(N);
	d.resize(N);
	cin >> X >> Y;
	X--; Y--;
	VP A(N);
	REP(i, N)cin >> A[i].first >> A[i].second;
	REP(i, M) {
		int u, v; cin >> u >> v; u--; v--;
		ld dis = dd(A[u], A[v]);
		G[u].push_back((edge) { v, dis });
		G[v].push_back((edge) { u, dis });
	}



	dikstra(X);
	printf("%.15Lf\n", d[Y]);
	return 0;
}

0