結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー 👑 kmjpkmjp
提出日時 2020-05-30 00:04:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 188 ms / 2,000 ms
コード長 1,285 bytes
コンパイル時間 2,404 ms
コンパイル使用メモリ 202,848 KB
実行使用メモリ 18,676 KB
最終ジャッジ日時 2024-04-24 02:44:54
合計ジャッジ時間 7,091 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
8,576 KB
testcase_01 AC 5 ms
8,448 KB
testcase_02 AC 80 ms
13,288 KB
testcase_03 AC 110 ms
17,136 KB
testcase_04 AC 114 ms
17,384 KB
testcase_05 AC 79 ms
17,260 KB
testcase_06 AC 79 ms
17,256 KB
testcase_07 AC 30 ms
11,008 KB
testcase_08 AC 99 ms
17,792 KB
testcase_09 AC 13 ms
9,600 KB
testcase_10 AC 47 ms
12,544 KB
testcase_11 AC 33 ms
11,264 KB
testcase_12 AC 23 ms
9,600 KB
testcase_13 AC 80 ms
13,344 KB
testcase_14 AC 95 ms
15,496 KB
testcase_15 AC 112 ms
16,364 KB
testcase_16 AC 55 ms
11,652 KB
testcase_17 AC 129 ms
16,920 KB
testcase_18 AC 40 ms
10,388 KB
testcase_19 AC 114 ms
16,980 KB
testcase_20 AC 31 ms
10,800 KB
testcase_21 AC 45 ms
10,752 KB
testcase_22 AC 104 ms
15,908 KB
testcase_23 AC 6 ms
8,576 KB
testcase_24 AC 6 ms
8,576 KB
testcase_25 AC 22 ms
9,472 KB
testcase_26 AC 59 ms
12,684 KB
testcase_27 AC 60 ms
12,084 KB
testcase_28 AC 102 ms
15,256 KB
testcase_29 AC 15 ms
9,344 KB
testcase_30 AC 117 ms
16,564 KB
testcase_31 AC 76 ms
15,032 KB
testcase_32 AC 52 ms
12,276 KB
testcase_33 AC 122 ms
18,676 KB
testcase_34 AC 42 ms
10,700 KB
testcase_35 AC 114 ms
16,472 KB
testcase_36 AC 6 ms
8,576 KB
testcase_37 AC 5 ms
8,576 KB
testcase_38 AC 5 ms
8,704 KB
testcase_39 AC 6 ms
8,704 KB
testcase_40 AC 5 ms
8,704 KB
testcase_41 AC 188 ms
17,920 KB
testcase_42 AC 48 ms
11,392 KB
testcase_43 AC 83 ms
13,440 KB
testcase_44 AC 31 ms
10,368 KB
testcase_45 AC 81 ms
13,440 KB
testcase_46 AC 4 ms
8,448 KB
testcase_47 AC 4 ms
8,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;
int S,T;
int X[202020],Y[202020];
vector<int> E[202020];
double D[202020];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M>>S>>T;
	S--,T--;
	FOR(i,N) cin>>X[i]>>Y[i];
	FOR(i,M) {
		cin>>x>>y;
		E[x-1].push_back(y-1);
		E[y-1].push_back(x-1);
	}
	
	FOR(i,N) D[i]=1e9;
	D[S]=0;
	priority_queue<pair<double,int>> Q;
	Q.push({0,S});
	while(Q.size()) {
		double co=-Q.top().first;
		int cur=Q.top().second;
		Q.pop();
		if(D[cur]!=co) continue;
		FORR(e,E[cur]) {
			double d=co+hypot(X[cur]-X[e],Y[cur]-Y[e]);
			if(D[e]>d) {
				D[e]=d;
				Q.push({-d,e});
			}
		}
		
	}
	_P("%.12lf\n",D[T]);
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0