結果

問題 No.622 点と三角柱の内外判定
ユーザー furafura
提出日時 2020-06-01 04:36:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,500 ms
コード長 971 bytes
コンパイル時間 1,687 ms
コンパイル使用メモリ 201,420 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-30 19:43:11
合計ジャッジ時間 2,662 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 AC 1 ms
6,940 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 1 ms
6,944 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 2 ms
6,944 KB
testcase_18 AC 1 ms
6,940 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 1 ms
6,940 KB
testcase_23 AC 1 ms
6,940 KB
testcase_24 AC 2 ms
6,944 KB
testcase_25 AC 1 ms
6,944 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 1 ms
6,940 KB
testcase_28 AC 1 ms
6,944 KB
testcase_29 AC 1 ms
6,940 KB
testcase_30 AC 1 ms
6,940 KB
testcase_31 AC 1 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

class point3{
public:
	double x,y,z;
	point3 operator-(const point3& p)const{ return {x-p.x,y-p.y,z-p.z}; }
};

point3 operator*(double c,const point3& p){ return {c*p.x,c*p.y,c*p.z}; }

double abs(const point3& p){ return sqrt(p.x*p.x+p.y*p.y+p.z*p.z); }

double dot(const point3& p,const point3& q){
	return p.x*q.x+p.y*q.y+p.z*q.z;
}

point3 cross(const point3& p,const point3& q){
	return {p.y*q.z-p.z*q.y,p.z*q.x-p.x*q.z,p.x*q.y-p.y*q.x};
}

int main(){
	point3 a,b,c,p;
	scanf("%lf%lf%lf",&a.x,&a.y,&a.z);
	scanf("%lf%lf%lf",&b.x,&b.y,&b.z);
	scanf("%lf%lf%lf",&c.x,&c.y,&c.z);
	scanf("%lf%lf%lf",&p.x,&p.y,&p.z);

	point3 n=cross(b-a,c-a);
	n=1/abs(n)*n;

	p=p-dot(p,n)*n;
	double s1=dot(cross(p-a,b-a),n);
	double s2=dot(cross(p-b,c-b),n);
	double s3=dot(cross(p-c,a-c),n);
	if((s1>0 && s2>0 && s3>0)
	|| (s1<0 && s2<0 && s3<0)) puts("YES");
	else puts("NO");

	return 0;
}
0