QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#260414 | #6517. Computational Geometry | zhaoyuecheng | WA | 0ms | 3984kb | C++14 | 964b | 2023-11-22 09:16:48 | 2023-11-22 09:16:49 |
Judging History
answer
#include <bits/stdc++.h>
#define N 5005
#define inf 5000000000000000000ll
typedef long long ll;
using namespace std;
int n;
ll f[N][N];
struct vec
{
int x,y;
inline vec operator-(const vec& b)const{return {x-b.x,y-b.y};}
}p[N];
ll calc(int,int);
ll dis2(vec a,vec b){return 1ll*(a.x-b.x)*(a.x-b.x)+1ll*(a.y-b.y)*(a.y-b.y);}
ll cro(vec a,vec b){return 1ll*a.x*b.y-1ll*a.y*b.x;}
int main()
{
ll ans;
int i,j,T;
scanf("%d",&T);
while(T--)
{
ans=inf;
scanf("%d",&n);
for(i=1;i<=n;++i)
scanf("%d %d",&p[i].x,&p[i].y);
for(i=0;i<=n;++i)
for(j=0;j<=n;++j)
f[i][j]=-1;
for(i=1;i<=n;++i)
for(j=i+2;j<=n;++j)
if(j%n+1!=i&&cro(p[i+1]-p[i],p[j]-p[i])!=0)
ans=min(ans,calc(i,j)+calc(j,i));
printf("%lld\n",ans);
}
return 0;
}
ll calc(int l,int r)
{
if(l==r)return 0;
if(f[l][r]!=-1)return f[l][r];
return f[l][r]=max(dis2(p[l],p[r]),max(calc(l%n+1,r),calc(l,(r+n-2)%n+1)));
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3928kb
input:
2 4 1 0 2 0 1 1 0 0 6 10 4 9 7 5 7 4 5 6 4 9 3
output:
4 44
result:
ok 2 number(s): "4 44"
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3984kb
input:
713 8 8 25 3 15 0 5 10 0 19 2 24 6 23 15 15 34 8 25 16 18 25 10 32 1 23 0 14 21 0 27 2 32 6 7 16 15 8 20 1 16 0 12 16 0 21 1 24 5 7 15 1 18 0 24 8 27 15 4 19 0 17 7 8 4 10 20 0 30 15 0 14 10 6 15 0 24 10 21 14 12 14 7 11 0 3 7 18 7 16 9 12 10 6 9 0 4 5 0 15 1 9 0 23 8 13 14 6 24 0 34 1 41 11 37 20 1...
output:
1075 1389 706 687 1550 497 300 1668 471 162 519 190 786 983 367 930 580 524 509 275 617 298 146 1330 494 965 599 1321 866 1210 233 398 560 1548 871 938 366 500 371 1118 1222 1994 712 586 858 624 697 575 1274 882 1035 406 934 670 990 1231 513 2871 939 2735 1610 834 721 585 203 198 1666 617 1166 326 2...
result:
wrong answer 120th numbers differ - expected: '294', found: '284'