QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#196541 | #6517. Computational Geometry | ucup-team870# | WA | 1ms | 3640kb | C++14 | 2.0kb | 2023-10-01 18:51:12 | 2023-10-01 18:51:13 |
Judging History
answer
#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=l; i<=r; i++)
#define per(i,l,r) for(int i=l;i>=r;i--)
#define IOS {cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);}
using namespace std;
typedef long long ll;
const int N=5e3+5;
struct P{
int x,y;
}q[N*2];
P operator -(P a,P b){
return {a.x-b.x,a.y-b.y};
}
bool coline(P a,P b){
return a.x*b.y==a.y*b.x;
}
ll dis(P a,P b){
return 1ll*(a.x-b.x)*(a.x-b.x)+1ll*(a.y-b.y)*(a.y-b.y);
}
ll ans[N][N],ma[N*2];
void slv(){
int n;cin>>n;
auto cal=[&](int x){return (x%n+n)%n;};
rep(i,0,n-1){
cin>>q[i].x>>q[i].y; q[i+n]=q[i];
}
rep(i,0,n-1)rep(j,0,n-1)ans[i][j]=0;
rep(i,0,2*n-1)ma[i]=0;
per(i,n*2-2,n){
rep(j,i+1,min(2*n-1,i+n-2))ma[j]=max(ma[j],dis(q[i],q[j]));
}
per(i,n-1,0){
rep(j,i+1,i+n-2)ma[j]=max(ma[j],dis(q[i],q[j]));
ll val=ma[i+1]; int ok=0;
rep(j,i+2,i+n-2){
if(!coline(q[j]-q[j-1],q[j-1]-q[j-2]))ok=1;
val=max(val,ma[j]);
if(ok)ans[i][j%n]+=val;//cout<<i<<' '<<j<<endl;
}
}
// cout<<ans[0][2]<<'\n';
reverse(q,q+n); rep(i,0,n-1)q[i+n]=q[i];
rep(i,0,2*n-1)ma[i]=0;
per(i,n*2-2,n){
rep(j,i+1,min(2*n-1,i+n-2))ma[j]=max(ma[j],dis(q[i],q[j]));
}
per(i,n-1,0){
rep(j,i+1,i+n-2)ma[j]=max(ma[j],dis(q[i],q[j]));
ll val=ma[i+1]; int ok=0;
rep(j,i+2,i+n-2){
if(!coline(q[j]-q[j-1],q[j-1]-q[j-2]))ok=1;
val=max(val,ma[j]);
if(ok)ans[cal(n-1-i)][cal(n-1-j)]+=val;
}
}
ll res=5e18;
rep(i,0,n-1){
assert(ans[i][i+1]==0);
rep(j,i+2,n-1){
assert(ans[i][j]==ans[j][i]);
if(i==0 && j==n-1)continue;
res=min(res,ans[i][j]);
}
}
cout<<res<<'\n';
}
int main() {
IOS
int T;cin>>T;
while(T--)slv();
return 0;
}
/*
2
4
1 0
2 0
1 1
0 0
6
10 4
9 7
5 7
4 5
6 4
9 3
1000000000
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3616kb
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: 1ms
memory: 3640kb
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 1448 871 938 366 500 371 1118 1222 1994 712 586 858 624 697 575 1274 882 1035 406 850 670 990 1231 513 2871 939 2701 1610 834 721 585 203 198 1666 617 769 326 21...
result:
wrong answer 34th numbers differ - expected: '1548', found: '1448'