結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー ttkkggwwttkkggww
提出日時 2020-05-29 22:07:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 363 ms / 2,000 ms
コード長 967 bytes
コンパイル時間 1,925 ms
コンパイル使用メモリ 174,364 KB
実行使用メモリ 22,964 KB
最終ジャッジ日時 2024-04-23 22:42:11
合計ジャッジ時間 9,513 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
9,940 KB
testcase_01 AC 5 ms
9,924 KB
testcase_02 AC 169 ms
15,044 KB
testcase_03 AC 235 ms
22,964 KB
testcase_04 AC 232 ms
21,284 KB
testcase_05 AC 188 ms
21,072 KB
testcase_06 AC 190 ms
21,252 KB
testcase_07 AC 66 ms
12,004 KB
testcase_08 AC 244 ms
19,176 KB
testcase_09 AC 24 ms
10,564 KB
testcase_10 AC 109 ms
13,964 KB
testcase_11 AC 76 ms
12,388 KB
testcase_12 AC 50 ms
11,584 KB
testcase_13 AC 171 ms
16,716 KB
testcase_14 AC 196 ms
18,804 KB
testcase_15 AC 231 ms
19,744 KB
testcase_16 AC 113 ms
14,280 KB
testcase_17 AC 248 ms
20,300 KB
testcase_18 AC 80 ms
12,992 KB
testcase_19 AC 240 ms
20,116 KB
testcase_20 AC 64 ms
12,280 KB
testcase_21 AC 99 ms
13,544 KB
testcase_22 AC 212 ms
19,232 KB
testcase_23 AC 7 ms
10,308 KB
testcase_24 AC 7 ms
10,052 KB
testcase_25 AC 45 ms
11,560 KB
testcase_26 AC 125 ms
15,080 KB
testcase_27 AC 129 ms
15,136 KB
testcase_28 AC 224 ms
19,284 KB
testcase_29 AC 28 ms
11,332 KB
testcase_30 AC 236 ms
20,260 KB
testcase_31 AC 161 ms
18,180 KB
testcase_32 AC 107 ms
14,424 KB
testcase_33 AC 230 ms
20,868 KB
testcase_34 AC 85 ms
12,980 KB
testcase_35 AC 237 ms
20,260 KB
testcase_36 AC 6 ms
10,052 KB
testcase_37 AC 7 ms
10,312 KB
testcase_38 AC 6 ms
10,052 KB
testcase_39 AC 7 ms
10,176 KB
testcase_40 AC 5 ms
10,052 KB
testcase_41 AC 363 ms
20,112 KB
testcase_42 AC 102 ms
12,772 KB
testcase_43 AC 181 ms
15,136 KB
testcase_44 AC 63 ms
11,556 KB
testcase_45 AC 178 ms
14,756 KB
testcase_46 AC 5 ms
9,920 KB
testcase_47 AC 4 ms
9,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<double,int>;
vector<ll> g[2*100000];
vector<pair<ll,ll>> vp;
double G[200000];
int n,m;
int X,Y;

int main()
{
	cin >> n >> m;
	cin >> X >> Y;
	X--;Y--;
	for(int i = 0;i < n;i++)
	{
		int x,y;
		cin >> x >> y;
		vp.emplace_back(x,y);
	}
	for(int i = 0;i<m;i++)
	{
		int x,y;
		cin >> x >> y;
		x--;y--;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	for(int i =0;i<200000;i++)
	{
		G[i] = 1e9;
	}
	priority_queue<P,vector<P>,greater<P>>PQ;
	G[X] = 0.0;
	PQ.emplace(0.0,X);

	while(!PQ.empty())
	{
		auto now = PQ.top();
		PQ.pop();
		int v = now.second;
		//cout<<v<<endl;
		if(G[v]!=now.first)continue;
		//cout<<v<<endl;
		for(auto i: g[v])
		{
			double div = sqrt((vp[i].first-vp[v].first)*(vp[i].first-vp[v].first)+(vp[i].second-vp[v].second)*(vp[i].second-vp[v].second));
			if(G[i]>G[v]+div)
			{
				G[i]=G[v]+div;
				PQ.emplace(G[i],i);
			}
		}
	}
	printf("%.7lf\n",G[Y]);

}
0