結果

問題 No.622 点と三角柱の内外判定
ユーザー 👑 horiesinitihoriesiniti
提出日時 2018-03-27 08:57:14
言語 Ruby
(3.3.0)
結果
AC  
実行時間 85 ms / 1,500 ms
コード長 1,004 bytes
コンパイル時間 51 ms
コンパイル使用メモリ 11,300 KB
実行使用メモリ 15,336 KB
最終ジャッジ日時 2023-09-07 18:55:05
合計ジャッジ時間 4,465 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,284 KB
testcase_01 AC 82 ms
15,260 KB
testcase_02 AC 83 ms
15,300 KB
testcase_03 AC 81 ms
15,148 KB
testcase_04 AC 79 ms
15,148 KB
testcase_05 AC 80 ms
15,060 KB
testcase_06 AC 80 ms
15,144 KB
testcase_07 AC 79 ms
15,236 KB
testcase_08 AC 83 ms
15,040 KB
testcase_09 AC 84 ms
15,064 KB
testcase_10 AC 82 ms
15,064 KB
testcase_11 AC 80 ms
15,048 KB
testcase_12 AC 81 ms
15,240 KB
testcase_13 AC 80 ms
15,136 KB
testcase_14 AC 81 ms
15,164 KB
testcase_15 AC 83 ms
15,064 KB
testcase_16 AC 84 ms
15,060 KB
testcase_17 AC 85 ms
15,144 KB
testcase_18 AC 84 ms
15,184 KB
testcase_19 AC 83 ms
15,064 KB
testcase_20 AC 82 ms
15,164 KB
testcase_21 AC 82 ms
15,252 KB
testcase_22 AC 84 ms
15,296 KB
testcase_23 AC 83 ms
15,256 KB
testcase_24 AC 81 ms
15,336 KB
testcase_25 AC 83 ms
15,044 KB
testcase_26 AC 84 ms
15,252 KB
testcase_27 AC 81 ms
15,100 KB
testcase_28 AC 81 ms
15,136 KB
testcase_29 AC 82 ms
15,060 KB
testcase_30 AC 81 ms
15,092 KB
testcase_31 AC 80 ms
15,068 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def f(e1,e2,e3)
	a1=e1[0]-e3[0]
	b1=e1[1]-e3[1]
	a2=e2[0]-e3[0]
	b2=e2[1]-e3[1]
	return a1*b2-a2*b1
end


x0,y0,z0=gets.split.map{|e| e.to_f}
x1,y1,z1=gets.split.map{|e| e.to_f}
x2,y2,z2=gets.split.map{|e| e.to_f}
x,y,z=gets.split.map{|e| e.to_f}

a1=x1-x0
a2=y1-y0
a3=z1-z0

b1=x2-x0
b2=y2-y0
b3=z2-z0

p1=a2*b3-a3*b2
q1=a3*b1-a1*b3
r1=a1*b2-a2*b1

t=(p1*(x0-x)+q1*(y0-y)+r1*(z0-z))/(p1**2+q1**2+r1**2)
tx=x+t*p1
ty=y+t*q1
tz=z+t*r1


tx=tx-x0
ty=ty-y0
tz=tz-z0
x1=x1-x0
y1=y1-y0
z1=z1-z0
x2=x2-x0
y2=y2-y0
z2=z2-z0
x0=0
y0=0
z0=0

t1=0
t2=0
t3=0

if x1*y2-y1*x2!=0
	#xy bad z
	t1=f([x0,y0],[x1,y1],[tx,ty])
	t2=f([x1,y1],[x2,y2],[tx,ty])
	t3=f([x2,y2],[x0,y0],[tx,ty])
elsif x1*z2-z1*x2!=0
	#xz bad y
	t1=f([x0,z0],[x1,z1],[tx,tz])
	t2=f([x1,z1],[x2,z2],[tx,tz])
	t3=f([x2,z2],[x0,z0],[tx,tz])
else
	#yz bad x
	t1=f([y0,z0],[y1,z1],[ty,tz])
	t2=f([y1,z1],[y2,z2],[ty,tz])
	t3=f([y2,z2],[y0,z0],[ty,tz])	
end
if t1<0 && t2<0 && t3<0
	puts "YES"
elsif t1>0 && t2>0 && t3>0
	puts "YES"
else
	puts "NO"
end
0