QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#549360#7521. Find the Gapparamec1um#WA 0ms3872kbC++201.7kb2024-09-06 14:45:212024-09-06 14:45:22

Judging History

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

  • [2024-09-06 14:45:22]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3872kb
  • [2024-09-06 14:45:21]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int maxn=60;
const double eps=1e-12;
#define IN inline
struct Point{
	double x,y,z;
	IN Point operator+(const Point &t)const{return {x+t.x,y+t.y,z+t.z};}
	IN Point operator-(const Point &t)const{return {x-t.x,y-t.y,z-t.z};}
	IN Point operator*(const Point &t)const{return {y*t.z-z*t.y,z*t.x-x*t.z,x*t.y-y*t.x};}
	IN Point operator*(const double &t)const{return{x*t,y*t,z*t};}
}a[maxn];
IN double sqr(double x){return x*x;}
IN double dis(Point a){return sqr(a.x)+sqr(a.y)+sqr(a.z);}

double ans=1e18;
void solve(){
	int n;
	cin>>n;
	for(int i=1;i<=n;++i){
		cin>>a[i].x>>a[i].y>>a[i].z;
	}
	for(int i=1;i<=n;++i){
		for(int j=i+1;j<=n;++j){
			for(int k=j+1;k<=n;++k){
				Point p=a[i],q=a[j],r=a[k];
				Point no=(p-q)*(r-p);
				double d=dis(no);
				if(d<eps)continue;
				double dd=0;
				int f1=0,f2=0;
				int ii=0;
				for(int m=1;m<=n;++m){
					Point mm=a[m];
					double h=(no.x*(mm.x-p.x)+no.y*(mm.y-p.y)+no.z*(mm.z-p.z))/sqrt(d);
					// if(h>ans){
					// 	cout<<i<<' '<<j<<' '<<k<<'\n';
					// 	cout<<no.x<<' '<<no.y<<' '<<no.z<<'\n';
					// 	cout<<m<<'\n';
					// 	ans=h;
					// 	cout<<ans<<'\n';
					// }
					if(h<0)f1=1;
					if(h>0)f2=1;
					if(dd<fabs(h)){
						dd=fabs(h);
						ii=m;
					}
				}
				if(f1*f2==0&&ans>dd){
					ans=min(ans,dd);
					// cout<<i<<' '<<j<<' '<<k<<'\n';
					// cout<<ii<<'\n';
					// cout<<no.x<<' '<<no.y<<' '<<no.z<<'\n';
					// cout<<ans<<'\n';
				}
			}
		}
	}
	cout<<fixed<<setprecision(15);
	cout<<ans<<'\n';
}
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//fstream in("in.txt",ios::in);cin.rdbuf(in.rdbuf());
	int T=1;
	while(T--)solve();
}

详细

Test #1:

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

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.000000000000000

result:

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

Test #2:

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

input:

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

output:

0.707106781186547

result:

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

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3872kb

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:

1000000000000000000.000000000000000

result:

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