結果

問題 No.1069 電柱 / Pole (Hard)
ユーザー chocoruskchocorusk
提出日時 2020-05-29 23:49:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,040 bytes
コンパイル時間 1,734 ms
コンパイル使用メモリ 150,796 KB
実行使用メモリ 14,924 KB
最終ジャッジ日時 2024-04-24 05:18:53
合計ジャッジ時間 3,910 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
using Pd=pair<double, int>;
int n, m, k;
vector<P> g[200020];
double de[200020];
const double INF=1e18;
bool dame[200020];
bool damee[200020];
int p[200020], q[200020];
pair<double, vector<int>> dijkstra(int s, int t){
	priority_queue<Pd, vector<Pd>, greater<Pd>> que;
	double d[2020];
	int pr[2020];
	fill(d, d+n, INF);
	d[s]=0;
	que.push({0, s});
	while(!que.empty()){
		auto p=que.top(); que.pop();
		int x=p.second;
		if(d[x]<p.first) continue;
		for(auto q:g[x]){
			int y=q.first;
			if(dame[y] || damee[q.second]) continue;
			if(d[y]>d[x]+de[q.second]){
				d[y]=d[x]+de[q.second];
				que.push({d[y], y});
				pr[y]=q.second;
			}
		}
	}
	vector<int> ret;
	if(d[t]>=INF/2){
		return make_pair(INF, ret);
	}
	int z=t;
	while(z!=s){
		ret.push_back(pr[z]);
		if(p[pr[z]]==z) z=q[pr[z]];
		else z=p[pr[z]];
	}
	reverse(ret.begin(), ret.end());
	return make_pair(d[t], ret);
}
int main()
{
	cin>>n>>m>>k;
	int x, y; cin>>x>>y; x--; y--;
	double a1[200020], b1[200020];
	for(int i=0; i<n; i++) cin>>a1[i]>>b1[i];
	for(int i=0; i<m; i++){
		cin>>p[i]>>q[i];
		p[i]--; q[i]--;
		de[i]=sqrt((a1[p[i]]-a1[q[i]])*(a1[p[i]]-a1[q[i]])+(b1[p[i]]-b1[q[i]])*(b1[p[i]]-b1[q[i]]));
		g[p[i]].push_back({q[i], i});
		g[q[i]].push_back({p[i], i});
	}
	double ans[11];
	auto p0=dijkstra(x, y);
	vector<int> a[11];
	vector<pair<double, vector<int>>> b;
	a[0]=p0.second;
	ans[0]=p0.first;
	int k0=k;
	for(int i=1; i<k; i++){
		int z=x;
		vector<int> v;
		double d0=0;
		for(int j=0; j<a[i-1].size(); j++){
			int w;
			if(p[a[i-1][j]]==z) w=q[a[i-1][j]];
			else w=p[a[i-1][j]];
			vector<int> myon;
			for(int l=0; l<i; l++){
			    if(a[l].size()<=j) continue;
				bool same=1;
				for(int m=0; m<j; m++){
					if(a[i-1][m]!=a[l][m]){
						same=0; break;
					}
				}
				if(same){
					damee[a[l][j]]=1;
					myon.push_back(a[l][j]);
				}
			}
			auto r=dijkstra(z, y);
			if(r.first<INF/2){
				vector<int> nuo;
				for(int l=0; l<j; l++) nuo.push_back(a[i-1][l]);
				for(auto e:r.second) nuo.push_back(e);
				b.push_back(make_pair(r.first+d0, r.second));
			}
			for(auto f:myon) damee[f]=0;
			dame[z]=1;
			d0+=de[a[i-1][j]];
			v.push_back(z);
			z=w;
		}
		if(b.empty()){
			k0=i; break;
		}
		sort(b.begin(), b.end(), greater<pair<double, vector<int>>>());
		b.erase(unique(b.begin(), b.end()), b.end());
		a[i]=b.back().second; ans[i]=b.back().first; b.pop_back();
		for(auto u:v) dame[u]=0;
	}
	for(int i=0; i<k; i++){
		if(i<k0) printf("%.12lf\n", ans[i]);
		else printf("-1\n");
	}
	return 0;
}
0