結果

問題 No.622 点と三角柱の内外判定
ユーザー cielciel
提出日時 2018-09-11 00:42:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 140 ms / 1,500 ms
コード長 998 bytes
コンパイル時間 253 ms
コンパイル使用メモリ 11,144 KB
実行使用メモリ 31,824 KB
最終ジャッジ日時 2023-09-02 01:20:24
合計ジャッジ時間 7,650 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 139 ms
30,100 KB
testcase_01 AC 135 ms
30,184 KB
testcase_02 AC 137 ms
31,748 KB
testcase_03 AC 136 ms
30,132 KB
testcase_04 AC 136 ms
29,992 KB
testcase_05 AC 136 ms
31,664 KB
testcase_06 AC 136 ms
31,648 KB
testcase_07 AC 137 ms
31,660 KB
testcase_08 AC 134 ms
31,744 KB
testcase_09 AC 136 ms
30,124 KB
testcase_10 AC 137 ms
30,080 KB
testcase_11 AC 137 ms
30,028 KB
testcase_12 AC 136 ms
31,728 KB
testcase_13 AC 136 ms
30,016 KB
testcase_14 AC 136 ms
30,092 KB
testcase_15 AC 137 ms
30,096 KB
testcase_16 AC 137 ms
29,848 KB
testcase_17 AC 138 ms
30,080 KB
testcase_18 AC 137 ms
31,816 KB
testcase_19 AC 137 ms
30,012 KB
testcase_20 AC 139 ms
30,184 KB
testcase_21 AC 137 ms
30,304 KB
testcase_22 AC 139 ms
31,824 KB
testcase_23 AC 137 ms
29,908 KB
testcase_24 AC 140 ms
30,192 KB
testcase_25 AC 137 ms
31,628 KB
testcase_26 AC 136 ms
31,616 KB
testcase_27 AC 138 ms
30,148 KB
testcase_28 AC 137 ms
30,160 KB
testcase_29 AC 137 ms
29,952 KB
testcase_30 AC 135 ms
30,092 KB
testcase_31 AC 137 ms
30,312 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import copy,math,numpy
def mul(a,b):return numpy.array(a).dot(b)

def rotateTriangle(*_):
	d=copy.deepcopy(list(_))
	for i in range(len(d)-1,-1,-1):
		d[i][0]-=d[0][0]
		d[i][1]-=d[0][1]
		d[i][2]-=d[0][2]
	d=list(zip(*d))
	thetay=-math.atan2(d[2][1],d[0][1])
	d=mul([[math.cos(thetay),0,-math.sin(thetay)],[0,1,0],[math.sin(thetay),0,math.cos(thetay)]],d)
	thetaz=-math.atan2(d[1][1],d[0][1])
	d=mul([[math.cos(thetaz),-math.sin(thetaz),0],[math.sin(thetaz),math.cos(thetaz),0],[0,0,1]],d)
	thetax=-math.atan2(d[2][2],d[1][2])
	d=mul([[1,0,0],[0,math.cos(thetax),-math.sin(thetax)],[0,math.sin(thetax),math.cos(thetax)]],d)
	d=list(zip(*d))
	return [e[0:2] for e in d]

import sys
a=[list(map(float,sys.stdin.readline().split())) for _ in range(4)]
for e in a:
	assert(all(-1e6<=f<=1e6 for f in e))
b=rotateTriangle(*a)
for i in range(3):
	edgex=b[(i+1)%3][0]-b[i][0]
	edgey=b[(i+1)%3][1]-b[i][1]
	vx=b[3][0]-b[i][0]
	vy=b[3][1]-b[i][1]
	if edgex*vy-edgey*vx<0:
		print('NO')
		exit()
print('YES')
0