QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#32741#1182. LighthousesWu_RenAC ✓2229ms15540kbC++171.2kb2022-05-23 11:19:252022-05-23 11:19:26

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-23 11:19:26]
  • 评测
  • 测评结果:AC
  • 用时:2229ms
  • 内存:15540kb
  • [2022-05-23 11:19:25]
  • 提交

answer

#include <bits/stdc++.h>
typedef long double ld;
const ld inf=1e18;
using namespace std;
int n,m,x[610],y[610];
ld f[610][610][2];
bool e[610][610];
ld dis(int i,int j){
	return sqrtl(1ll*(x[i]-x[j])*(x[i]-x[j])+1ll*(y[i]-y[j])*(y[i]-y[j]));
}
void add(int u,int v){
	if(u>v) swap(u,v);
	e[u][v]=e[v][u]=1;
	f[u][v][0]=f[u][v][1]=dis(u,v); 
}
void sol(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d%d",&x[i],&y[i]);
	for(int i=n+1;i<=2*n;i++) x[i]=x[i-n],y[i]=y[i-n];
	for(int i=1;i<=2*n;i++) for(int j=1;j<=2*n;j++) e[i][j]=0,f[i][j][0]=f[i][j][1]=-(i!=j)*inf;
	scanf("%d",&m);
	for(int i=1,x,y;i<=m;i++) scanf("%d%d",&x,&y),add(x,y),add(x+n,y),add(x,y+n),add(x+n,y+n);
	ld ans=0;
	for(int len=1;len<=n;len++) for(int l=1;l+len-1<=2*n;l++){
		int r=l+len-1;
		for(int i=l+1;i<r;i++){
			if(e[l][r]){
				f[l][r][0]=max(f[l][r][0],f[i][r][1]+dis(l,r));
				f[l][r][1]=max(f[l][r][1],f[l][i][0]+dis(l,r));
			}
			if(e[i][r]) f[l][r][1]=max(f[l][r][1],f[l][i][1]+dis(i,r));
			if(e[l][i]) f[l][r][0]=max(f[l][r][0],f[i][r][0]+dis(l,i));
		}
		ans=max({ans,f[l][r][0],f[l][r][1]});
	}
	printf("%.12Lf\n",ans);
}
int main(){
	int T;
	scanf("%d",&T);
	while(T--) sol();
}

详细

Test #1:

score: 100
Accepted
time: 3ms
memory: 3856kb

input:

2
4
0 0
1 0
1 1
0 1
3
1 3
2 4
3 4
4
0 0
1 0
1 1
0 1
4
1 4
4 3
3 2
2 1

output:

2.414213562373
3.000000000000

result:

ok 2 numbers

Test #2:

score: 0
Accepted
time: 6ms
memory: 3960kb

input:

450
7
0 0
260338181 86092533
323066179 107441010
424697382 278447352
71444106 1000000000
-575302618 804979842
-258577414 97804732
20
2 3
2 5
1 3
7 4
2 1
5 3
6 2
7 5
4 2
3 6
1 7
5 6
4 6
4 5
3 4
7 2
6 1
1 5
7 6
4 1
5
0 0
713930457 800419774
94147955 958520832
-286069543 1000000000
-262432976 698118841...

output:

4765927085.197136793286
3445280472.471964442637
4807.744303066480
3190.426973230076
4345171440.261608531699
6514.458110993524
3773167316.242773545906
2276985.135787842709
1033.226499853735
2035605.489658919959
5547331390.472334377468
0.000000000000
2480.599962469619
2348460308.029507686151
7779.5832...

result:

ok 450 numbers

Test #3:

score: 0
Accepted
time: 2229ms
memory: 15540kb

input:

10
295
0 0
14682701 503060
25046284 1037424
36405162 1792084
39349419 2119133
68531516 5963501
88143287 8803232
105612921 11584151
110634846 12446595
115510397 13365788
123709362 15371938
138667321 19292100
143732922 20680197
152527267 23117317
161336760 25663342
175610584 29864225
179534317 3102751...

output:

138692526440.221286743879
142741536635.014158621430
210677906142.053471386433
44669007984.586183805019
143288343239.696915224195
7617016839.570424831007
49984226404.877367675304
199989775093.763986334205
206539582580.724332526326
45567211025.837231300771

result:

ok 10 numbers