QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#644024#9227. Henry the PlumbertipharethWA 1ms3824kbC++141.7kb2024-10-16 10:06:172024-10-16 10:06:17

Judging History

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

  • [2024-10-16 10:06:17]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3824kb
  • [2024-10-16 10:06:17]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long double db;
const db eps=1e-8;
int sgn(db x)
{
	if(fabs(x)<eps)return 0;
	if(x<0)return -1;
	else return 1;
}
struct node{db x,y,z;}a,aa,b,bb;
struct line{node a,b;}L;
node operator+(node a,node b){return {a.x+b.x,a.y+b.y,a.z+b.z};}
node operator-(node a,node b){return {a.x-b.x,a.y-b.y,a.z-b.z};}
db operator*(node a,node b){return a.x*b.x+a.y*b.y+a.z*b.z;}
node operator*(node a,db b){return {a.x*b,a.y*b,a.z*b};}
node operator/(node a,db b){return {a.x/b,a.y/b,a.z/b};}
node operator^(node a,node b){return {a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x};}
struct plane{node p,l;}A,B;
void cross(plane A,plane B,line &L)
{
	node oo=A.l^B.l;
	node v=A.l^oo;
	db d=fabs(B.l*v);
	node q=A.p+(v*(B.l*(B.p-A.p))/d);
	L={q,q+oo};
	return;
}
int T;
int main()
{
	cin >> T;
	while(T--)
	{
		cin >> a.x >> a.y >> a.z;
		cin >> aa.x >> aa.y;
		cin >> b.x >> b.y >> b.z;
		cin >> bb.x >> bb.y;
		if(!sgn((a-b)*aa) && !sgn((a-b)*bb))
		{
			cout << 2 << endl;
			continue;
		}
		if((!sgn(aa.x) && !sgn(bb.x)) || (!sgn(aa.y) && !sgn(bb.y)))
		{
			cout << 4 << endl;
			continue;
		}
		if(sgn(aa.x) && sgn(bb.x) && sgn(aa.y) && sgn(bb.y) && !sgn(aa.x*bb.y-aa.y*bb.x))
		{
			cout << 4 << endl;
			continue;
		}
		A={a,aa},B={b,bb};
		cross(A,B,L);
		db x=L.a.x,y=L.a.y;
		if((!sgn(a.x-x) && !sgn(a.y-y)) || ((!sgn(b.x-x) && !sgn(b.y-y))))
		{
			if(sgn(a.z-b.z))
				cout << 3 << endl;
			else cout << 4 << endl;
			continue;
		}
		db k2=1,k1=-a.z-b.z,C=(x-a.x)*(x-b.x)+(y-a.y)*(y-b.y)+a.z*b.z;
		db delta=k1*k1-4*k2*C;
		if(sgn(delta)>=0)
			cout << 3 << endl;
		else cout << 4 << endl;
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
-1 -1 3
1 1
2 2 3
2 2
5 5 1
3 0
7 6 -2
1 -2

output:

4
3

result:

ok 2 number(s): "4 3"

Test #2:

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

input:

100
-13 -5 -7
-19 19
-19 -13 0
-7 15
-20 20 19
-17 18
20 -20 -1
18 -19
-18 15 -14
-19 18
19 -20 6
20 -19
-12 9 1
7 -16
-13 -14 -8
8 -13
-19 16 9
20 -19
19 -18 -11
19 -18
19 20 -8
12 20
-11 -9 18
-19 -18
8 11 -13
12 -18
18 13 8
4 -18
-16 20 17
-19 18
20 -18 -3
20 -19
-17 -20 -5
-18 -19
19 16 15
19 20...

output:

4
4
4
4
4
4
3
4
4
4
4
4
4
4
4
4
3
4
4
4
4
4
4
4
4
4
4
4
4
3
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
3
4
4
4
4
3
4
4
4
4
4
4
4
4
4
4
4
3
4
3
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
3
4
4
4
4
4
4
4
4
4
4
4

result:

wrong answer 11th numbers differ - expected: '3', found: '4'