QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#112018 | #1182. Lighthouses | qinsanma | WA | 6ms | 5732kb | C++14 | 2.2kb | 2023-06-09 14:56:34 | 2023-06-09 14:56:37 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
double x[1000],y[1000];
double dist(int a,int b)
{
return sqrt((x[a]-x[b])*(x[a]-x[b])+(y[a]-y[b])*(y[a]-y[b]));
}
bool a[1000][1000];
double dp[1000][1000][2];
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
for(int i=1; i<=n; i++)
{
cin>>x[i]>>y[i];
x[i+n]=x[i];
y[i+n]=y[i];
}
for(int i=1; i<=2*n; i++)
{
for(int j=1; j<=2*n; j++)
{
a[i][j]=0;
dp[i][j][0]=dp[i][j][1]=0;
}
}
int m;
cin>>m;
double ans=0;
for(int i=1; i<=m; i++)
{
int xx,yy;
cin>>xx>>yy;
a[xx][yy]=1;
a[yy][xx]=1;
a[xx+n][yy]=1;
a[xx][yy+n]=1;
a[xx+n][yy+n]=1;
dp[xx][yy][0]=dp[yy][xx][0]=dp[xx+n][yy][0]=dp[xx][yy+n][0]=dp[xx+n][yy+n][0]=dist(xx,yy);
dp[xx][yy][1]=dp[yy][xx][1]=dp[xx+n][yy][1]=dp[xx][yy+n][1]=dp[xx+n][yy+n][1]=dist(xx,yy);
ans=max(ans,dist(xx,yy));
}
for(int len=n; len>=2; len--)
{
for(int l=1; l+len-1<=2*n; l++)
{
int r=l+len-1;
for(int j=l+1; j<r; j++)
{
if(a[l][j])
{
dp[l][j][1]=max(dp[l][j][1],dp[l][r][0]+dist(l,j));
dp[j][r][0]=max(dp[j][r][0],dp[l][r][0]+dist(l,j));
ans=max(ans,dp[l][j][1]);
ans=max(ans,dp[j][r][0]);
}
if(a[r][j])
{
dp[j][r][0]=max(dp[j][r][0],dp[l][r][1]+dist(r,j));
dp[l][j][1]=max(dp[l][j][1],dp[l][r][1]+dist(r,j));
ans=max(ans,dp[l][j][1]);
ans=max(ans,dp[j][r][0]);
}
}
}
}
cout<<fixed<<setprecision(9)<<ans<<endl;
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 5668kb
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.414213562 3.000000000
result:
ok 2 numbers
Test #2:
score: -100
Wrong Answer
time: 6ms
memory: 5732kb
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.197136879 3445280472.471964836 4502.892056658 3190.426973230 4345171440.261609077 6514.458110994 3773167316.242773056 2276985.135787843 1033.226499854 1384906.088883877 5547331390.472334862 0.000000000 2480.599962470 2348460308.029507637 7340.196060115 4406116330.036901474 1366112.7952040...
result:
wrong answer 3rd numbers differ - expected: '4807.7443031', found: '4502.8920567', error = '0.0634086'