結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー kotatsugamekotatsugame
提出日時 2020-05-29 21:35:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 381 ms / 2,000 ms
コード長 897 bytes
コンパイル時間 977 ms
コンパイル使用メモリ 92,668 KB
実行使用メモリ 23,436 KB
最終ジャッジ日時 2024-04-23 20:29:01
合計ジャッジ時間 8,833 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
10,112 KB
testcase_01 AC 5 ms
9,984 KB
testcase_02 AC 178 ms
16,608 KB
testcase_03 AC 242 ms
23,436 KB
testcase_04 AC 244 ms
23,312 KB
testcase_05 AC 200 ms
23,312 KB
testcase_06 AC 198 ms
23,140 KB
testcase_07 AC 71 ms
13,312 KB
testcase_08 AC 250 ms
22,400 KB
testcase_09 AC 24 ms
11,008 KB
testcase_10 AC 110 ms
15,360 KB
testcase_11 AC 77 ms
13,696 KB
testcase_12 AC 57 ms
13,440 KB
testcase_13 AC 179 ms
18,520 KB
testcase_14 AC 202 ms
20,044 KB
testcase_15 AC 238 ms
20,980 KB
testcase_16 AC 124 ms
16,576 KB
testcase_17 AC 262 ms
22,184 KB
testcase_18 AC 88 ms
14,720 KB
testcase_19 AC 251 ms
21,312 KB
testcase_20 AC 66 ms
13,056 KB
testcase_21 AC 110 ms
16,324 KB
testcase_22 AC 219 ms
20,492 KB
testcase_23 AC 7 ms
10,240 KB
testcase_24 AC 8 ms
10,240 KB
testcase_25 AC 51 ms
13,184 KB
testcase_26 AC 130 ms
16,552 KB
testcase_27 AC 134 ms
16,656 KB
testcase_28 AC 233 ms
21,516 KB
testcase_29 AC 32 ms
12,160 KB
testcase_30 AC 242 ms
22,012 KB
testcase_31 AC 172 ms
19,152 KB
testcase_32 AC 109 ms
15,632 KB
testcase_33 AC 235 ms
22,668 KB
testcase_34 AC 89 ms
14,716 KB
testcase_35 AC 240 ms
22,408 KB
testcase_36 AC 6 ms
9,984 KB
testcase_37 AC 8 ms
10,240 KB
testcase_38 AC 6 ms
10,240 KB
testcase_39 AC 7 ms
10,240 KB
testcase_40 AC 5 ms
9,984 KB
testcase_41 AC 381 ms
23,040 KB
testcase_42 AC 103 ms
14,080 KB
testcase_43 AC 186 ms
16,896 KB
testcase_44 AC 62 ms
12,544 KB
testcase_45 AC 187 ms
16,640 KB
testcase_46 AC 4 ms
9,984 KB
testcase_47 AC 5 ms
10,112 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:12:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   12 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<queue>
using namespace std;
int N,M,X,Y;
int x[2<<17],y[2<<17];
vector<pair<int,double> >G[2<<17];
double dist[2<<17];
main()
{
	cin>>N>>M>>X>>Y;X--,Y--;
	for(int i=0;i<N;i++)
	{
		cin>>x[i]>>y[i];
	}
	for(int i=0;i<M;i++)
	{
		int u,v;cin>>u>>v;u--,v--;
		double c=hypot(x[u]-x[v],y[u]-y[v]);
		G[u].push_back(make_pair(v,c));
		G[v].push_back(make_pair(u,c));
	}
	for(int i=0;i<N;i++)dist[i]=1e150;
	dist[X]=0;
	priority_queue<pair<double,int> >P;
	P.push(make_pair(0,X));
	while(!P.empty())
	{
		double c=-P.top().first;
		int u=P.top().second;P.pop();
		if(dist[u]<c-1e-10)continue;
		for(pair<int,double>p:G[u])
		{
			int v=p.first;
			double nxt=c+p.second;
			if(dist[v]>nxt)
			{
				dist[v]=nxt;
				P.push(make_pair(-nxt,v));
			}
		}
	}
	cout<<fixed<<setprecision(16)<<dist[Y]<<endl;
}
0