QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#236968#7521. Find the GapEvierWA 3ms3880kbC++14889b2023-11-04 12:06:172023-11-04 12:06:18

Judging History

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

  • [2023-11-04 12:06:18]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3880kb
  • [2023-11-04 12:06:17]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define y1 y114514
int n,x[51],y[51],z[51];
ld ans=1e15;
bool flag;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>x[i]>>y[i]>>z[i];
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			for(int k=j+1;k<=n;k++){
				int x1=x[i],y1=y[i],z1=z[i],x2=x[j],y2=y[j],z2=z[j],x3=x[k],y3=y[k],z3=z[k];
				ll a=(y2-y1)*(z3-z1)-(y3-y1)*(z2-z1);
				ll b=(z2-z1)*(x3-x1)-(z3-z2)*(x2-x1);
				ll c=(x2-x1)*(y3-y1)-(x3-x1)*(y2-y1);
				if(a==0&&b==0&&c==0)continue;
				flag=1;
				ll d=a*x1+b*y1+c*z1;
				d=-d;
				ld mx=-1e15,mi=1e15;
				for(int l=1;l<=n;l++){
					ld tmp=a*x[l]+b*y[l]+c*z[l]+d;
					ld p=a*a+b*b+c*c;p=sqrt(p);
					tmp/=p;
					mx=max(mx,tmp),mi=min(mi,tmp);
				}
				ans=min(ans,mx-mi);
			}
		}
	}
	if(!flag)puts("0");
	else printf("%.12Lf",ans);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

8
1 1 1
1 1 2
1 2 1
1 2 2
2 1 1
2 1 2
2 2 1
2 2 2

output:

1.000000000000

result:

ok found '1.000000000', expected '1.000000000', error '0.000000000'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3880kb

input:

5
1 1 1
1 2 1
1 1 2
1 2 2
2 1 1

output:

0.707106781187

result:

ok found '0.707106781', expected '0.707106781', error '0.000000000'

Test #3:

score: -100
Wrong Answer
time: 3ms
memory: 3860kb

input:

50
973 1799 4431
1036 1888 4509
1099 1977 4587
1162 2066 4665
1225 2155 4743
1288 2244 4821
1351 2333 4899
1414 2422 4977
1540 2600 5133
1603 2689 5211
1666 2778 5289
1729 2867 5367
1792 2956 5445
1855 3045 5523
1918 3134 5601
1981 3223 5679
2044 3312 5757
2107 3401 5835
2170 3490 5913
2296 3668 606...

output:

4895.000000000000

result:

wrong answer 1st numbers differ - expected: '0.0000000', found: '4895.0000000', error = '4895.0000000'