QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#547950#7521. Find the Gapretired_midlights#WA 1ms3900kbC++141.5kb2024-09-05 13:46:532024-09-05 13:46:54

Judging History

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

  • [2024-09-05 13:46:54]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3900kb
  • [2024-09-05 13:46:53]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
using namespace std;
struct ve
{
	ll x,y,z;
	ll operator*(ve b)const
	{
		return x*b.x+y*b.y+z*b.z;
	}
	ve operator|(ve b)const
	{
		return (ve){y*b.z-z*b.y,
		z*b.x-x*b.z,
		x*b.y-y*b.x
		};
	}
	ve operator-(ve b)const
	{
		return (ve){x-b.x,y-b.y,z-b.z};
	}
	double len()
	{
		return sqrt(x*x+y*y+z*z);
	}
}a[100];
int main()
{
	int i,j,k,l,n,m;
	ll x,y,z;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&x,&y,&z);
		a[i]=(ve){x,y,z};
	}
	if(n<4)
	{
		printf("0.00\n");
		return 0;
	}
	double ans=1e10;
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			for(k=j+1;k<n;k++)
			{
				ve norm=(a[i]-a[j])|(a[i]-a[k]);
				if(norm.len()<1e-8)
				{
					continue;
				}
				int po=0,ne=0;
				double ma=0;
				for(l=0;l<n;l++)
				{
					x=norm*(a[i]-a[l]);
					if(x>=0)po++;
					if(x<=0)ne++;
					ma=max(ma,abs(x)*1.0/norm.len());
				}
				if(po==n||ne==n)
				{
					ans=min(ans,ma);
				}
			}
		}
	}
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			for(k=j+1;k<n;k++)
			{
				for(l=k+1;l<n;l++)
				{
					ve norm = (a[i]-a[j])|(a[k]-a[l]);
					if(norm.len()<1e-8)
					{
						continue;
					}
					x=0;
					for(int p=0;p<n;p++)
					{
						if((norm*(a[i]-a[p])>=0&&norm*(a[k]-a[p])<=0)||(norm*(a[i]-a[p])<=0&&norm*(a[k]-a[p])>=0))
						{
							x++;
						}
					}
					if(x==n)
						ans=min(ans,abs((a[i]-a[k])*norm)/norm.len());
				}
			}
		}
	}
	printf("%.10lf",ans);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

result:

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

Test #2:

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

input:

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

output:

0.7071067812

result:

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

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 3832kb

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:

10000000000.0000000000

result:

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