QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#153476#6517. Computational GeometryqzezWA 1ms3900kbC++141.4kb2023-08-30 07:42:432023-08-30 07:42:45

Judging History

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

  • [2023-08-30 07:42:45]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3900kb
  • [2023-08-30 07:42:43]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<typename T>
ostream& operator << (ostream &out,const vector<T>&x){
	if(x.empty())return out<<"[]";
	out<<'['<<x[0];
	for(int len=x.size(),i=1;i<len;i++)out<<','<<x[i];
	return out<<']';
}
template<typename T>
vector<T> ary(const T *a,int l,int r){
	return vector<T>{a+l,a+1+r};
}
template<typename T>
void debug(T x){
	cerr<<x<<'\n';
}
template<typename T,typename ...S>
void debug(T x,S ...y){
	cerr<<x<<' ',debug(y...);
}
struct vec{
	int x,y;
};
vec operator - (const vec &a,const vec &b){
	return {a.x-b.x,a.y-b.y};
}
ll dot(const vec &a,const vec &b){
	return 1ll*a.x*b.x+1ll*a.y*b.y;
}
ll dis2(const vec &a){
	return dot(a,a);
}
const int N=1e4+10;
int T,n;
vec a[N];
ll f[N][N];
void get(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&a[i].x,&a[i].y);
	}
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			ll d=dis2(a[i]-a[j]);
			f[i][j]=max(f[i][j],d);
			f[j][i+n]=max(f[j][i+n],d);
			f[i+n][j+n]=max(f[i+n][j+n],d);
		}
	}
	for(int i=n+n;i>=1;i--){
		for(int j=i+1;j<=n+n;j++){
			f[i][j]=max({f[i+1][j],f[i][j-1],f[i][j]});
		}
	}
	ll ans=LONG_LONG_MAX;
	for(int i=1;i<=n;i++){
		for(int j=i+2;j+(i==1)<=n;j++){
			ans=min(ans,f[i][j]+f[j][i+n]);
		}
	}
	printf("%lld\n",ans);
}
int main(){
	for(scanf("%d",&T);T--;)get();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3628kb

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: 3900kb

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
1533
1543
1556
1670
1670
1670
2075
2314
1670
2139
1670
1927
2075
2314
2250
2250
2250
2250
2054
2314
2054
1954
2451
2054
2423
2423
2423
2451
2473
2318
2018
2018
2573
2423
2473
2573
2573
2423
2423
2423
3273
2573
2573
3130
2573
3130
3130
3273
3273
3273
2765
3130
2765
3273
3273
2765
3794
2573
3794
...

result:

wrong answer 2nd numbers differ - expected: '1389', found: '1533'