fork(1) download
  1. def g2(p1,p2,a,b)
  2. as=[]
  3. [b,p1,p2].each{|e|
  4. as<<e.zip(a).map{|e2| e2[0]-e2[1]}
  5. }
  6. e1=as[0]
  7. e2=as[1]
  8. e3=as[2]
  9. return e1[0]*(e2[1]*e3[2]-e3[1]*e2[2])+e1[1]*(e2[0]*e3[2]-e2[2]*e3[0])+e1[2]*(e2[0]*e3[1]-e3[0]*e2[1])
  10. end
  11. def g(p1,p2,a,b)
  12. t=g2(p1,p2,a,b)
  13. return (t==0)?0:(t>0)?1:2
  14. end
  15. def f()
  16. return gets.split(" ").map{|e| e.to_i}
  17. end
  18. a=f()
  19. b=f()
  20. cs=[]
  21. ds=[0,0,0]
  22. 3.times{
  23. cs<<f()
  24. }
  25. 3.times{|i|
  26. ds[g(cs[i],cs[(i+1)%3],a,b)]+=1
  27. }
  28. ans="HIT"
  29. s1=g2(cs[1],cs[2],a,cs[0])
  30. if s1>=0 then
  31. ans="MISS" if ds[0]+ds[1]==3
  32. else
  33. ans="MISS" if ds[0]+ds[2]==3
  34. end
  35. puts ans
Success #stdin #stdout 0.01s 6248KB
stdin
-10 0 0
10 0 0
0 10 0
0 10 10
0 0 10
stdout
HIT