結果

問題 No.1069 電柱 / Pole (Hard)
ユーザー 👑 kmjpkmjp
提出日時 2020-05-30 01:21:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,607 bytes
コンパイル時間 3,176 ms
コンパイル使用メモリ 224,232 KB
実行使用メモリ 17,792 KB
最終ジャッジ日時 2024-04-24 06:28:16
合計ジャッジ時間 9,797 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
8,832 KB
testcase_01 AC 5 ms
8,576 KB
testcase_02 AC 4 ms
8,832 KB
testcase_03 AC 4 ms
8,576 KB
testcase_04 AC 1,577 ms
13,184 KB
testcase_05 TLE -
testcase_06 AC 11 ms
8,960 KB
testcase_07 AC 10 ms
8,704 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 9 ms
8,960 KB
testcase_11 AC 5 ms
8,704 KB
testcase_12 AC 6 ms
8,576 KB
testcase_13 AC 9 ms
8,576 KB
testcase_14 AC 8 ms
8,744 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 14 ms
8,960 KB
testcase_20 WA -
testcase_21 AC 19 ms
8,832 KB
testcase_22 AC 7 ms
8,832 KB
testcase_23 AC 54 ms
8,832 KB
testcase_24 WA -
testcase_25 AC 14 ms
8,576 KB
testcase_26 AC 10 ms
8,704 KB
testcase_27 AC 12 ms
8,704 KB
testcase_28 AC 11 ms
8,960 KB
testcase_29 AC 5 ms
8,832 KB
testcase_30 AC 5 ms
8,832 KB
testcase_31 AC 4 ms
8,448 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 4 ms
8,832 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 6 ms
8,524 KB
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 12 ms
8,864 KB
testcase_49 AC 10 ms
8,960 KB
testcase_50 AC 6 ms
8,448 KB
testcase_51 WA -
testcase_52 AC 6 ms
8,832 KB
testcase_53 AC 12 ms
8,704 KB
testcase_54 WA -
testcase_55 WA -
testcase_56 AC 5 ms
8,704 KB
testcase_57 WA -
testcase_58 AC 4 ms
8,600 KB
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
testcase_62 AC 4 ms
8,732 KB
testcase_63 AC 4 ms
8,832 KB
testcase_64 WA -
testcase_65 AC 4 ms
8,576 KB
testcase_66 WA -
testcase_67 AC 5 ms
8,832 KB
testcase_68 WA -
testcase_69 AC 10 ms
8,960 KB
testcase_70 AC 7 ms
9,088 KB
testcase_71 AC 11 ms
9,188 KB
testcase_72 AC 7 ms
8,960 KB
testcase_73 AC 11 ms
9,088 KB
testcase_74 AC 10 ms
9,344 KB
testcase_75 AC 9 ms
9,216 KB
testcase_76 WA -
testcase_77 WA -
testcase_78 WA -
testcase_79 AC 16 ms
8,576 KB
testcase_80 WA -
testcase_81 AC 12 ms
8,832 KB
testcase_82 WA -
権限があれば一括ダウンロードができます

ソースコード

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,K;
int S,T;
int X[202020],Y[202020];
vector<int> E[202020];
double D[2020];
vector<int> P[2020];

pair<double,vector<int>> hoge(int start,set<pair<int,int>> NG) {
	int i;
	
	FOR(i,N) D[i]=1e9, P[i].clear();
	
	D[start]=0;
	P[start].push_back(start);
	priority_queue<pair<double,int>> Q;
	Q.push({0,start});
	while(Q.size()) {
		double co=-Q.top().first;
		int cur=Q.top().second;
		Q.pop();
		if(D[cur]!=co) continue;
		FORR(e,E[cur]) {
			if(NG.count({e,cur})) continue;
			if(NG.count({cur,e})) continue;
			if(count(ALL(P[cur]),e)) continue;
			double d=co+hypot(X[cur]-X[e],Y[cur]-Y[e]);
			if(D[e]>d) {
				D[e]=d;
				P[e]=P[cur];
				P[e].push_back(e);
				Q.push({-d,e});
			}
		}
	}
	
	return {D[T],P[T]};
	
}


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M>>K>>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);
	}
	
	vector<pair<double,vector<int>>> ret;
	vector<pair<double,vector<int>>> cand;
	set<pair<int,int>> NG;
	ret.push_back(hoge(S,NG));
	while(ret.size()<K) {
		double sum=0;
		vector<int> pre;
		FOR(x,ret.back().second.size()-1) {
			if(x) {
				pre.push_back(ret.back().second[x-1]);
				sum+=hypot(X[ret.back().second[x-1]]-X[ret.back().second[x]],Y[ret.back().second[x-1]]-Y[ret.back().second[x]]);
			}
			NG.clear();
			FOR(i,ret.size()) {
				if(ret[i].second.size()<x+2) continue;
				FOR(y,x+1) if(ret[i].second[y]!=ret.back().second[y]) break;
				if(y!=x+1) continue;
				NG.insert({ret[i].second[x],ret[i].second[x+1]});
			}
			auto v = pre;
			auto a=hoge(ret.back().second[x],NG);
			FORR(b,a.second) v.push_back(b);
			
			cand.push_back({a.first+sum,v});
		}
		
		
		
		sort(ALL(cand));
		if(cand.empty()) break;
		if(cand[0].first>1e8) break;
		ret.push_back(cand[0]);
		cand.erase(cand.begin());
	}
	
	FOR(i,K) {
		if(i<ret.size()) {
			_P("%.12lf\n",ret[i].first);
		}
		else {
			_P("-1\n");
		}
	}
	
	
}


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