QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#356286#6517. Computational GeometryDjangle162857#WA 2ms5924kbC++201.3kb2024-03-17 17:17:452024-03-17 17:17:45

Judging History

你现在查看的是最新测评结果

  • [2024-03-17 17:17:45]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:5924kb
  • [2024-03-17 17:17:45]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef long long ll;
const int N=10005;
ll x[N],y[N];
//short dpi[N][N],dpj[N][N],Rj[N][N];
ll dp[N][N];
ll dis(int i,int j) {return (x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]);}
//bool cmp(int i1,int j1,int i2,int j2) {
//	return dis(i1,j1)>dis(i2,j2);
//}//如果i1,j1大于i2,j2 
int t,n;
signed main() {
	cin>>t;
	while(t--) {
		cin>>n;
		for(int i=1;i<=n;i++) {
			scanf("%lld%lld",&x[i],&y[i]);
			x[i+n]=x[i],y[i+n]=y[i];
		}
		for(int i=1;i<=2*n-1;i++)	{
			//dpi[i][i+1]=i;
			//dpj[i][i+1]=i+1;
			//Rk[i][i+1]=i+1;
			dp[i][i+1]=dis(i,i+1);
		}
		/*or(int i=1;i<=2*n;i++){
		for(int j=1;j<=2*n;j++) {
			cout<<dis(i,j)<<" "; 
		}
		cout<<endl;
		}	*/
		for(int i=2*n-2;i>=1;i--) {
			int nowmax=dis(i,i+1);
			for(int j=i+2;j<=2*n;j++) {
				nowmax=max(nowmax,dis(i,j));
				dp[i][j]=max(dp[i+1][j],nowmax);
			}
		}
		/*for(int i=1;i<=2*n;i++){
		for(int j=1;j<=2*n;j++) {
			cout<<dp[i][j]<<" "; 
		}
		cout<<endl;
		}*/	
		int ans=0x7f7f7f7f7f7f7f7fll;
		for(int i=1;i<=n;i++) {
			for(int j=i+2;j<=i+n-2;j++) 
			//cout<<i<<" "<<j<<" "<<i+n<<" "<<dis(i,j)<<" "<<dis(j,i+n)<<endl; 
				ans=min(ans,dp[i][j]+dp[j][i+n]);
		}
		cout<<ans<<endl;
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 5924kb

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: 2ms
memory: 5816kb

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'