QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#32740#1182. LighthousesWu_RenWA 2ms5796kbC++171.2kb2022-05-23 11:18:282022-05-23 11:18:28

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:18:28]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:5796kb
  • [2022-05-23 11:18:28]
  • 提交

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<=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: 1ms
memory: 3664kb

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: -100
Wrong Answer
time: 2ms
memory: 5796kb

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.471964442404
4785.140699524971
3190.426973230076
4345171440.261608531699
6514.458110993524
3773167316.242773545906
2276985.135787842709
1033.226499853735
2035605.489658919959
5547331390.472334377002
0.000000000000
2480.599962469619
2348460308.029507686151
6871.5176...

result:

wrong answer 3rd numbers differ - expected: '4807.7443031', found: '4785.1406995', error = '0.0047015'