結果

問題 No.1069 電柱 / Pole (Hard)
ユーザー 沙耶花沙耶花
提出日時 2020-05-29 22:35:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,471 bytes
コンパイル時間 2,890 ms
コンパイル使用メモリ 218,476 KB
実行使用メモリ 6,932 KB
最終ジャッジ日時 2024-04-25 12:09:55
合計ジャッジ時間 6,338 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 91 ms
5,376 KB
testcase_05 WA -
testcase_06 AC 78 ms
5,376 KB
testcase_07 AC 25 ms
6,180 KB
testcase_08 AC 16 ms
5,376 KB
testcase_09 AC 13 ms
5,792 KB
testcase_10 AC 9 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 6 ms
5,376 KB
testcase_13 AC 25 ms
5,376 KB
testcase_14 AC 23 ms
5,376 KB
testcase_15 AC 21 ms
5,736 KB
testcase_16 AC 7 ms
5,376 KB
testcase_17 AC 8 ms
5,376 KB
testcase_18 AC 8 ms
5,376 KB
testcase_19 AC 12 ms
5,904 KB
testcase_20 AC 17 ms
5,376 KB
testcase_21 AC 28 ms
5,376 KB
testcase_22 AC 31 ms
5,376 KB
testcase_23 AC 34 ms
5,376 KB
testcase_24 AC 17 ms
6,820 KB
testcase_25 AC 16 ms
6,820 KB
testcase_26 AC 98 ms
6,728 KB
testcase_27 AC 102 ms
6,820 KB
testcase_28 AC 99 ms
6,932 KB
testcase_29 AC 4 ms
5,376 KB
testcase_30 AC 3 ms
5,376 KB
testcase_31 WA -
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 1 ms
5,376 KB
testcase_35 AC 1 ms
5,376 KB
testcase_36 AC 2 ms
5,376 KB
testcase_37 AC 5 ms
5,376 KB
testcase_38 AC 5 ms
5,376 KB
testcase_39 AC 2 ms
5,376 KB
testcase_40 AC 4 ms
5,376 KB
testcase_41 AC 10 ms
5,376 KB
testcase_42 AC 6 ms
5,376 KB
testcase_43 AC 6 ms
5,376 KB
testcase_44 AC 12 ms
5,376 KB
testcase_45 AC 19 ms
5,376 KB
testcase_46 AC 12 ms
5,752 KB
testcase_47 AC 15 ms
5,376 KB
testcase_48 AC 13 ms
6,412 KB
testcase_49 AC 9 ms
5,376 KB
testcase_50 AC 4 ms
5,376 KB
testcase_51 AC 16 ms
5,540 KB
testcase_52 AC 4 ms
5,376 KB
testcase_53 AC 13 ms
5,500 KB
testcase_54 AC 2 ms
5,376 KB
testcase_55 AC 2 ms
5,376 KB
testcase_56 AC 1 ms
5,376 KB
testcase_57 AC 2 ms
5,376 KB
testcase_58 AC 2 ms
5,376 KB
testcase_59 AC 2 ms
5,376 KB
testcase_60 AC 2 ms
5,376 KB
testcase_61 AC 2 ms
5,376 KB
testcase_62 AC 2 ms
5,376 KB
testcase_63 AC 2 ms
5,376 KB
testcase_64 AC 3 ms
5,376 KB
testcase_65 AC 2 ms
5,376 KB
testcase_66 AC 2 ms
5,376 KB
testcase_67 AC 2 ms
5,376 KB
testcase_68 AC 2 ms
5,376 KB
testcase_69 AC 4 ms
5,376 KB
testcase_70 AC 4 ms
5,376 KB
testcase_71 AC 5 ms
5,376 KB
testcase_72 AC 3 ms
5,376 KB
testcase_73 AC 3 ms
5,376 KB
testcase_74 AC 5 ms
5,376 KB
testcase_75 AC 4 ms
5,376 KB
testcase_76 AC 13 ms
6,672 KB
testcase_77 AC 17 ms
6,040 KB
testcase_78 AC 2 ms
5,376 KB
testcase_79 AC 20 ms
5,760 KB
testcase_80 AC 11 ms
5,500 KB
testcase_81 AC 18 ms
6,020 KB
testcase_82 AC 16 ms
6,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000.0

double eps = 1e-7;

int main(){
	
	int N,M,K,X,Y;
	cin>>N>>M>>K>>X>>Y;
	
	X--;Y--;
	
	vector<double> x(N),y(N);
	for(int i=0;i<N;i++)cin>>x[i]>>y[i];
	
	vector<vector<pair<int,double>>> E(N,vector<pair<int,double>>());
	
	for(int i=0;i<M;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		double d = sqrt(pow(x[u]-x[v],2.0)+pow(y[u]-y[v],2.0));
		E[u].emplace_back(v,d);
		E[v].emplace_back(u,d);
	}
	
	vector<double> ans;
	vector<int> cnt(N,0);
	priority_queue<pair<pair<double,int>,vector<bool>>,vector<pair<pair<double,int>,vector<bool>>>,greater<pair<pair<double,int>,vector<bool>>>> Q;
	
	{
		vector<bool> t(N,false);
		t[X] = true;
		Q.emplace(make_pair(0.0,X),t);
	}


	while(Q.size()!=0){
		double D1 = Q.top().first.first;
		int from = Q.top().first.second;
		vector<bool> b = Q.top().second;
		Q.pop();
		if(cnt[from]>=K)continue;

		cnt[from]++;
		if(from==Y)ans.push_back(D1);
		for(int i=0;i<E[from].size();i++){
			int to = E[from][i].first;
			if(cnt[to]>=K)continue;
			if(b[to])continue;
			double D2 = E[from][i].second;
			vector<bool> t = b;
			t[to] = true;
			Q.emplace(make_pair(D1+D2,to),t);
		}
		//cout<<Q.top().first.first<<endl;
	}

	sort(ans.begin(),ans.end());
	for(int i=0;i<K;i++){
		if(i>=ans.size())cout<<-1<<endl;
		else cout<<fixed<<setprecision(10)<<ans[i]<<endl;
	}
	
	return 0;
}
0