QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#112021 | #1182. Lighthouses | qinsanma | WA | 11ms | 5676kb | C++14 | 2.2kb | 2023-06-09 14:59:12 | 2023-06-09 14:59:22 |
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[yy][xx+n]=1;
a[xx][yy+n]=1;
a[yy+n][xx]=1;
a[xx+n][yy+n]=1;
a[yy+n][xx+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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 3ms
memory: 5676kb
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: 11ms
memory: 3820kb
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 4525.495660199 3190.426973230 4345171440.261609077 6514.458110994 3773167316.242773056 2276985.135787843 1033.226499854 2035605.489658920 5547331390.472334862 0.000000000 2480.599962470 2348460308.029507637 7779.583217082 4406116330.036901474 1366112.7952040...
result:
wrong answer 3rd numbers differ - expected: '4807.7443031', found: '4525.4956602', error = '0.0587071'