Problem:


宇宙船 UAZ アドバンス号

 恒星歴 2005.11.5。あなたは宇宙船 UAZ アドバンス号の艦長として敵の宇宙船と交戦しようとしています。 幸い敵の宇宙船はまだこちらに気付かずに静止しています。また、すでに敵の宇宙座標は判明しており強力な直線のビームを放つ「フェザー砲」は発射準備を完了しています。あとは、発射命令を出すばかりです。

ところが、宇宙空間には、敵の設置したエネルギーバリアが存在しています。バリアは三角形をしており「フェザー砲」のビームをはね返してしまいます。また、ビームがバリアに当たれば敵に気付かれて逃げられてしまいます。事前に命中すると判定できなければ、発射命令は出せません。

そこで、UAZ アドバンス号、敵、バリアの位置の宇宙座標(3次元座標 x, y, z) を入力して、ビームがバリアをさけて敵に命中する場合は "HIT"、バリアに当たってしまう場合"MISS"と出力するプログラムを作成してください。

 ただし、バリアはアドバンス号から 3 角形に見えるものだけが対象であり、線分につぶれて見えるものはないものとします。また、バリアは 3 角形の頂点を含む境界でも有効であり、ビームをはね返すものとします。また、敵がバリア内にいる場合は"MISS"と出力して下さい。

x, y, z )を入力して、「フェ
ザー砲」がバリアをさけて敵に命中する場合は“HIT”、バリアに命中してはね返されてしまう場合“MISS”と出力し
て終了するプログラムを作成してください。

 ただし、バリアはアドバンス号から 3 角形に見えるものだけが対象であり、線分につぶれて見えるものはないも
のとします。また、バリアは 3 角形の頂点を含む境界でも有効であり、ビームをはね返すものとします。

-->

Input

入力データの形式は以下のとおりです：

1 行目は、UAZ アドバンス号の座標 (x, y, z) (整数、半角空白区切り)

2 行目は、敵の座標 (x, y, z) (整数、半角空白区切り)

3 行目は、バリアの頂点 1 の座標 (x, y, z) (整数、半角空白区切り)

4 行目は、バリアの頂点 2 の座標 (x, y, z ) (整数、半角空白区切り)

5 行目は、バリアの頂点 3 の座標 (x, y, z ) (整数、半角空白区切り)

Output

HIT または MISS と１行に出力してください。

Constraints

-100 ≤ x, y, z ≤ 100

UAZ アドバンス号と敵が同じ位置にいることはない。

Sample Input 1

-10 0 0
10 0 0
0 10 0
0 10 10
0 0 10

Output for the Sample Input 1

HIT

Sample Input 2

-10 6 6
10 6 6
0 10 0
0 10 10
0 0 10

Output for the Sample Input 2

MISS



Sample input:
-10 0 0
10 0 0
0 10 0
0 10 10
0 0 10


Sample output:
HIT

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math

# refs
# https://shikousakugo.wordpress.com/2012/06/27/ray-intersection-2/

def det(a, b, c):
    return a[0] * b[1] * c[2] + \
           a[2] * b[0] * c[1] + \
           a[1] * b[2] * c[0] - \
           a[2] * b[1] * c[0] - \
           a[1] * b[0] * c[2] - \
           a[0] * b[2] * c[1]

def sub(v0, v1):
    # v0 - v1
    return (v0[0] - v1[0], v0[1] - v1[1], v0[2] - v1[2])

# me
p0 = list(map(int, input().split()))

# enemy
p1 = list(map(int, input().split()))

# barrier
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

a = sub(p1, p0)
b = sub(A, B)
c = sub(A, C)
d = sub(A, p0)

t = det(d, b, c) / det(a, b, c)
u = det(a, d, c) / det(a, b, c)
v = det(a, b, d) / det(a, b, c)

if 0 <= u <= 1 and 0 <= v <= 1 and 0 <= u + v <= 1:
    print('MISS')
else:
    print('HIT')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math

# refs
# https://shikousakugo.wordpress.com/2012/06/27/ray-intersection-2/

def det(a, b, c):
    return a[0] * b[1] * c[2] + \
           a[2] * b[0] * c[1] + \
           a[1] * b[2] * c[0] - \
           a[2] * b[1] * c[0] - \
           a[1] * b[0] * c[2] - \
           a[0] * b[2] * c[1]

def sub(v0, v1):
    # v0 - v1
    return (v0[0] - v1[0], v0[1] - v1[1], v0[2] - v1[2])

# me
p0 = list(map(int, input().split()))

# enemy
p1 = list(map(int, input().split()))

# barrier
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

a = sub(p1, p0)
b = sub(A, B)
c = sub(A, C)
d = sub(A, p0)

t = det(d, b, c) / det(a, b, c)
u = det(a, d, c) / det(a, b, c)
v = det(a, b, d) / det(a, b, c)

lower = -0.0000001
upper = 1.0000001
if lower <= u <= upper and lower <= v <= upper and lower <= u + v <= upper:
    print('MISS')
else:
    print('HIT')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math

# refs
# https://shikousakugo.wordpress.com/2012/06/27/ray-intersection-2/

def det(a, b, c):
    return + a[0] * b[1] * c[2] \
           + a[2] * b[0] * c[1] \
           + a[1] * b[2] * c[0] \
           - a[2] * b[1] * c[0] \
           - a[1] * b[0] * c[2] \
           - a[0] * b[2] * c[1]

def sub(v0, v1):
    # v0 - v1
    return (v0[0] - v1[0], v0[1] - v1[1], v0[2] - v1[2])

# me
p0 = list(map(int, input().split()))

# enemy
p1 = list(map(int, input().split()))

# barrier
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

a = sub(p1, p0)
b = sub(A, B)
c = sub(A, C)
d = sub(A, p0)

denom = det(a, b, c)
if denom > 0:
    t = det(d, b, c) / denom
    u = det(a, d, c) / denom
    v = det(a, b, d) / denom

    lower = -0.0000001
    upper = 1.0000001
    if lower <= u <= upper and lower <= v <= upper and lower <= u + v <= upper:
        print('MISS')
    else:
        print('HIT')
else:
    print('HIT')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math

# refs
# https://shikousakugo.wordpress.com/2012/06/27/ray-intersection-2/

def det(a, b, c):
    return + a[0] * b[1] * c[2] \
           + a[2] * b[0] * c[1] \
           + a[1] * b[2] * c[0] \
           - a[2] * b[1] * c[0] \
           - a[1] * b[0] * c[2] \
           - a[0] * b[2] * c[1]

def sub(v0, v1):
    # v0 - v1
    return (v0[0] - v1[0], v0[1] - v1[1], v0[2] - v1[2])

# me
p0 = list(map(int, input().split()))

# enemy
p1 = list(map(int, input().split()))

# barrier
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

a = sub(p1, p0)
b = sub(A, B)
c = sub(A, C)
d = sub(A, p0)

denom = det(a, b, c)
lower = -0.0000001
upper = 1.0000001

if denom == 0:
    print('HIT')
elif denom > lower:
    t = det(d, b, c) / denom
    u = det(a, d, c) / denom
    v = det(a, b, d) / denom


    if lower <= u <= upper and lower <= v <= upper and lower <= u + v <= upper:
        print('MISS')
    else:
        print('HIT')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math

# refs
# https://shikousakugo.wordpress.com/2012/06/27/ray-intersection-2/

def det(a, b, c):
    return + a[0] * b[1] * c[2] \
           + a[2] * b[0] * c[1] \
           + a[1] * b[2] * c[0] \
           - a[2] * b[1] * c[0] \
           - a[1] * b[0] * c[2] \
           - a[0] * b[2] * c[1]

def sub(v0, v1):
    # v0 - v1
    return (v0[0] - v1[0], v0[1] - v1[1], v0[2] - v1[2])

# me
p0 = list(map(int, input().split()))

# enemy
p1 = list(map(int, input().split()))

# barrier
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

a = sub(p1, p0)
b = sub(A, B)
c = sub(A, C)
d = sub(A, p0)

denom = det(a, b, c)
lower = -0.0000001
upper = 1.0000001

if denom > lower:
    if denom <= 0:
        print('HIT')
    else:
        t = det(d, b, c) / denom
        u = det(a, d, c) / denom
        v = det(a, b, d) / denom

        if lower <= u <= upper and lower <= v <= upper and lower <= u + v <= upper:
            print('MISS')
        else:
            print('HIT')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math

# refs
# https://shikousakugo.wordpress.com/2012/06/27/ray-intersection-2/

def det(a, b, c):
    return + a[0] * b[1] * c[2] \
           + a[2] * b[0] * c[1] \
           + a[1] * b[2] * c[0] \
           - a[2] * b[1] * c[0] \
           - a[1] * b[0] * c[2] \
           - a[0] * b[2] * c[1]

def sub(v0, v1):
    # v0 - v1
    return (v0[0] - v1[0], v0[1] - v1[1], v0[2] - v1[2])

# me
p0 = list(map(int, input().split()))

# enemy
p1 = list(map(int, input().split()))

# barrier
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

a = sub(p1, p0)
b = sub(A, B)
c = sub(A, C)
d = sub(A, p0)

denom = det(a, b, c)
lower = -0.0000001
upper = 1.0000001

if denom > lower:
    if denom <= 0:
        print('MISS')
    else:
        t = det(d, b, c) / denom
        u = det(a, d, c) / denom
        v = det(a, b, d) / denom

        if lower <= u <= upper and lower <= v <= upper and lower <= u + v <= upper:
            print('MISS')
        else:
            print('HIT')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math

# refs
# https://shikousakugo.wordpress.com/2012/06/27/ray-intersection-2/

def det(a, b, c):
    return + a[0] * b[1] * c[2] \
           + a[2] * b[0] * c[1] \
           + a[1] * b[2] * c[0] \
           - a[2] * b[1] * c[0] \
           - a[1] * b[0] * c[2] \
           - a[0] * b[2] * c[1]

def sub(v0, v1):
    # v0 - v1
    return (v0[0] - v1[0], v0[1] - v1[1], v0[2] - v1[2])

# me
p0 = list(map(int, input().split()))

# enemy
p1 = list(map(int, input().split()))

# barrier
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

a = sub(p1, p0)
b = sub(A, B)
c = sub(A, C)
d = sub(A, p0)

denom = det(a, b, c)
lower = -0.0000001
upper = 1.0000001

if denom > lower:
    t = det(d, b, c) / denom
    u = det(a, d, c) / denom
    v = det(a, b, d) / denom

    if lower <= u <= upper and lower <= v <= upper and lower <= u + v <= upper:
        print('MISS')
    else:
        print('HIT')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math

# refs
# https://shikousakugo.wordpress.com/2012/06/27/ray-intersection-2/

def det(a, b, c):
    return + a[0] * b[1] * c[2] \
           + a[2] * b[0] * c[1] \
           + a[1] * b[2] * c[0] \
           - a[2] * b[1] * c[0] \
           - a[1] * b[0] * c[2] \
           - a[0] * b[2] * c[1]

def sub(v0, v1):
    # v0 - v1
    return (v0[0] - v1[0], v0[1] - v1[1], v0[2] - v1[2])

# me
p0 = list(map(int, input().split()))

# enemy
p1 = list(map(int, input().split()))

# barrier
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

a = sub(p1, p0)
b = sub(A, B)
c = sub(A, C)
d = sub(A, p0)

denom = det(a, b, c)
lower = -0.0000001
upper = 1.0000001

if denom > lower:
    if denom <= 0:
        print('MISS')
    else:
        t = det(d, b, c) / denom
        u = det(a, d, c) / denom
        v = det(a, b, d) / denom

        if lower <= u <= upper and lower <= v <= upper and lower <= u + v <= upper:
            print('MISS')
        else:
            print('HIT')
else:
    print('HIT')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math

# refs
# https://shikousakugo.wordpress.com/2012/06/27/ray-intersection-2/

def det(a, b, c):
    return + a[0] * b[1] * c[2] \
           + a[2] * b[0] * c[1] \
           + a[1] * b[2] * c[0] \
           - a[2] * b[1] * c[0] \
           - a[1] * b[0] * c[2] \
           - a[0] * b[2] * c[1]

def sub(v0, v1):
    # v0 - v1
    return (v0[0] - v1[0], v0[1] - v1[1], v0[2] - v1[2])

# me
p0 = list(map(int, input().split()))

# enemy
p1 = list(map(int, input().split()))

# barrier
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

a = sub(p1, p0)
b = sub(A, B)
c = sub(A, C)
d = sub(A, p0)

denom = det(a, b, c)
lower = -0.0000001
upper = 1.0000001

if denom > lower:
    if denom <= 0:
        print('HIT')
    else:
        t = det(d, b, c) / denom
        u = det(a, d, c) / denom
        v = det(a, b, d) / denom

        if lower <= u <= upper and lower <= v <= upper and lower <= u + v <= upper:
            print('MISS')
        else:
            print('HIT')
else:
    print('HIT')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math

# refs
# https://shikousakugo.wordpress.com/2012/06/27/ray-intersection-2/

def det(a, b, c):
    return + a[0] * b[1] * c[2] \
           + a[2] * b[0] * c[1] \
           + a[1] * b[2] * c[0] \
           - a[2] * b[1] * c[0] \
           - a[1] * b[0] * c[2] \
           - a[0] * b[2] * c[1]

def sub(v0, v1):
    # v0 - v1
    return (v0[0] - v1[0], v0[1] - v1[1], v0[2] - v1[2])

# me
p0 = list(map(int, input().split()))

# enemy
p1 = list(map(int, input().split()))

# barrier
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

a = sub(p1, p0)
b = sub(A, B)
c = sub(A, C)
d = sub(A, p0)

denom = det(a, b, c)
lower = -0.0000001
upper = 1.0000001

if denom > lower:
    if denom <= 0:
        print('HIT')
    else:
        t = det(d, b, c) / denom
        u = det(a, d, c) / denom
        v = det(a, b, d) / denom

        if lower <= u <= upper and lower <= v <= upper and lower <= u + v <= upper:
            print('MISS')
        else:
            print('HIT')
else:
    print('MISS')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math

# refs
# https://shikousakugo.wordpress.com/2012/06/27/ray-intersection-2/

def det(a, b, c):
    return + a[0] * b[1] * c[2] \
           + a[2] * b[0] * c[1] \
           + a[1] * b[2] * c[0] \
           - a[2] * b[1] * c[0] \
           - a[1] * b[0] * c[2] \
           - a[0] * b[2] * c[1]

def sub(v0, v1):
    # v0 - v1
    return (v0[0] - v1[0], v0[1] - v1[1], v0[2] - v1[2])

# me
p0 = list(map(int, input().split()))

# enemy
p1 = list(map(int, input().split()))

# barrier
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

a = sub(p1, p0)
b = sub(A, B)
c = sub(A, C)
d = sub(A, p0)

denom = det(a, b, c)
lower = -0.0000001
upper = 1.0000001

if denom > lower:
    if denom <= 0:
        print('HIT')
    else:
        t = det(d, b, c) / denom
        u = det(a, d, c) / denom
        v = det(a, b, d) / denom

        if lower <= u <= upper and lower <= v <= upper and lower <= u + v <= upper:
            print('MISS')
        else:
            if t > 0:
                print('HIT')
            else:
                print('MISS')
else:
    print('HIT')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math

# refs
# https://shikousakugo.wordpress.com/2012/06/27/ray-intersection-2/

def det(a, b, c):
    return + a[0] * b[1] * c[2] \
           + a[2] * b[0] * c[1] \
           + a[1] * b[2] * c[0] \
           - a[2] * b[1] * c[0] \
           - a[1] * b[0] * c[2] \
           - a[0] * b[2] * c[1]

def sub(v0, v1):
    # v0 - v1
    return (v0[0] - v1[0], v0[1] - v1[1], v0[2] - v1[2])

# me
p0 = list(map(int, input().split()))

# enemy
p1 = list(map(int, input().split()))

# barrier
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

a = sub(p1, p0)
b = sub(A, B)
c = sub(A, C)
d = sub(A, p0)

denom = det(a, b, c)
lower = -0.0000001
upper = 1.0000001

if denom > lower:
    if denom <= 0:
        print('HIT')
    else:
        t = det(d, b, c) / denom
        u = det(a, d, c) / denom
        v = det(a, b, d) / denom

        if t > 0 and lower <= u <= upper and lower <= v <= upper and lower <= u + v <= upper:
            print('MISS')
        else:
            print('HIT')
else:
    print('HIT')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math

# refs
# https://shikousakugo.wordpress.com/2012/06/27/ray-intersection-2/

def det(a, b, c):
    return + a[0] * b[1] * c[2] \
           + a[2] * b[0] * c[1] \
           + a[1] * b[2] * c[0] \
           - a[2] * b[1] * c[0] \
           - a[1] * b[0] * c[2] \
           - a[0] * b[2] * c[1]

def sub(v0, v1):
    # v0 - v1
    return (v0[0] - v1[0], v0[1] - v1[1], v0[2] - v1[2])

# me
p0 = list(map(int, input().split()))

# enemy
p1 = list(map(int, input().split()))

# barrier
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

a = sub(p1, p0)
b = sub(A, B)
c = sub(A, C)
d = sub(A, p0)

denom = det(a, b, c)
lower = -0.0000001
upper = 1.0000001

if denom > lower:
    if denom <= 0:
        print('HIT')
    else:
        t = det(d, b, c) / denom
        u = det(a, d, c) / denom
        v = det(a, b, d) / denom

        if t > lower and lower <= u <= upper and lower <= v <= upper and lower <= u + v <= upper:
            print('MISS')
        else:
            print('HIT')
else:
    print('HIT')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math

# refs
# https://shikousakugo.wordpress.com/2012/06/27/ray-intersection-2/

def det(a, b, c):
    return + a[0] * b[1] * c[2] \
           + a[2] * b[0] * c[1] \
           + a[1] * b[2] * c[0] \
           - a[2] * b[1] * c[0] \
           - a[1] * b[0] * c[2] \
           - a[0] * b[2] * c[1]

def sub(v0, v1):
    # v0 - v1
    return (v0[0] - v1[0], v0[1] - v1[1], v0[2] - v1[2])

# me
p0 = list(map(int, input().split()))

# enemy
p1 = list(map(int, input().split()))

# barrier
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

a = sub(p1, p0)
b = sub(A, B)
c = sub(A, C)
d = sub(A, p0)

denom = det(a, b, c)
lower = -0.000000001
upper = 1.000000001

if denom > lower:
    if denom <= 0:
        print('HIT')
    else:
        t = det(d, b, c) / denom
        u = det(a, d, c) / denom
        v = det(a, b, d) / denom

        if t > 0 and lower <= u <= upper and lower <= v <= upper and lower <= u + v <= upper:
            print('MISS')
        else:
            print('HIT')
else:
    print('HIT')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math

# refs
# https://shikousakugo.wordpress.com/2012/06/27/ray-intersection-2/

def det(a, b, c):
    return + a[0] * b[1] * c[2] \
           + a[2] * b[0] * c[1] \
           + a[1] * b[2] * c[0] \
           - a[2] * b[1] * c[0] \
           - a[1] * b[0] * c[2] \
           - a[0] * b[2] * c[1]

def sub(v0, v1):
    # v0 - v1
    return (v0[0] - v1[0], v0[1] - v1[1], v0[2] - v1[2])

# me
p0 = list(map(int, input().split()))

# enemy
p1 = list(map(int, input().split()))

# barrier
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

a = sub(p1, p0)
b = sub(A, B)
c = sub(A, C)
d = sub(A, p0)

denom = det(a, b, c)
lower = -0.000000
upper = 1.000000

if denom > lower:
    if denom <= 0:
        print('HIT')
    else:
        t = det(d, b, c) / denom
        u = det(a, d, c) / denom
        v = det(a, b, d) / denom

        if t > 0 and lower <= u <= upper and lower <= v <= upper and lower <= u + v <= upper:
            print('MISS')
        else:
            print('HIT')
else:
    print('HIT')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math

# refs
# https://shikousakugo.wordpress.com/2012/06/27/ray-intersection-2/

def det(a, b, c):
    return + a[0] * b[1] * c[2] \
           + a[2] * b[0] * c[1] \
           + a[1] * b[2] * c[0] \
           - a[2] * b[1] * c[0] \
           - a[1] * b[0] * c[2] \
           - a[0] * b[2] * c[1]

def sub(v0, v1):
    # v0 - v1
    return (v0[0] - v1[0], v0[1] - v1[1], v0[2] - v1[2])

# me
p0 = list(map(int, input().split()))

# enemy
p1 = list(map(int, input().split()))

# barrier
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

a = sub(p1, p0)
b = sub(A, B)
c = sub(A, C)
d = sub(A, p0)

denom = det(a, b, c)
lower = -0.00001
upper = 1.00001

if denom > lower:
    if denom <= 0:
        print('HIT')
    else:
        t = det(d, b, c) / denom
        u = det(a, d, c) / denom
        v = det(a, b, d) / denom

        if t > 0 and lower <= u <= upper and lower <= v <= upper and lower <= u + v <= upper:
            print('MISS')
        else:
            print('HIT')
else:
    print('HIT')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math

# refs
# https://shikousakugo.wordpress.com/2012/06/27/ray-intersection-2/

def det(a, b, c):
    return + a[0] * b[1] * c[2] \
           + a[2] * b[0] * c[1] \
           + a[1] * b[2] * c[0] \
           - a[2] * b[1] * c[0] \
           - a[1] * b[0] * c[2] \
           - a[0] * b[2] * c[1]

def sub(v0, v1):
    # v0 - v1
    return (v0[0] - v1[0], v0[1] - v1[1], v0[2] - v1[2])

# me
p0 = list(map(int, input().split()))

# enemy
p1 = list(map(int, input().split()))

# barrier
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

a = sub(p1, p0)
b = sub(A, B)
c = sub(A, C)
d = sub(A, p0)

denom = det(a, b, c)
lower = -0.0000001
upper = 1.0000001

if denom > lower:
    if denom <= 0:
        print('HIT')
    else:
        t = det(d, b, c) / denom
        u = det(a, d, c) / denom
        v = det(a, b, d) / denom

        if t < 0:
            print('MISS')
        elif lower <= u <= upper and lower <= v <= upper and lower <= u + v <= upper:
            print('MISS')
        else:
            print('HIT')
else:
    print('HIT')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math

# refs
# https://shikousakugo.wordpress.com/2012/06/27/ray-intersection-2/

def det(a, b, c):
    return + a[0] * b[1] * c[2] \
           + a[2] * b[0] * c[1] \
           + a[1] * b[2] * c[0] \
           - a[2] * b[1] * c[0] \
           - a[1] * b[0] * c[2] \
           - a[0] * b[2] * c[1]

def sub(v0, v1):
    # v0 - v1
    return (v0[0] - v1[0], v0[1] - v1[1], v0[2] - v1[2])

# me
p0 = list(map(int, input().split()))

# enemy
p1 = list(map(int, input().split()))

# barrier
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

a = sub(p1, p0)
b = sub(A, B)
c = sub(A, C)
d = sub(A, p0)

denom = det(a, b, c)
lower = -0.0000001
upper = 1.0000001

if denom > lower:
    if denom <= 0:
        print('HIT')
    else:
        t = det(d, b, c) / denom
        u = det(a, d, c) / denom
        v = det(a, b, d) / denom

        if t < lower:
            print('MISS')
        elif lower <= u <= upper and lower <= v <= upper and lower <= u + v <= upper:
            print('MISS')
        else:
            print('HIT')
else:
    print('HIT')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math

# refs
# https://shikousakugo.wordpress.com/2012/06/27/ray-intersection-2/

def det(a, b, c):
    return + a[0] * b[1] * c[2] \
           + a[2] * b[0] * c[1] \
           + a[1] * b[2] * c[0] \
           - a[2] * b[1] * c[0] \
           - a[1] * b[0] * c[2] \
           - a[0] * b[2] * c[1]

def sub(v0, v1):
    # v0 - v1
    return (v0[0] - v1[0], v0[1] - v1[1], v0[2] - v1[2])

# me
p0 = list(map(int, input().split()))

# enemy
p1 = list(map(int, input().split()))

# barrier
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

a = sub(p1, p0)
b = sub(A, B)
c = sub(A, C)
d = sub(A, p0)

denom = det(a, b, c)
lower = -0.0000001
upper = 1.0000001

if denom > 0:
    t = det(d, b, c) / denom
    u = det(a, d, c) / denom
    v = det(a, b, d) / denom

    if lower <= u <= upper and lower <= v <= upper and lower <= u + v <= upper:
        print('MISS')
    else:
        print('HIT')
else:
    print('HIT')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math

# refs
# https://shikousakugo.wordpress.com/2012/06/27/ray-intersection-2/

def det(a, b, c):
    return + a[0] * b[1] * c[2] \
           + a[2] * b[0] * c[1] \
           + a[1] * b[2] * c[0] \
           - a[2] * b[1] * c[0] \
           - a[1] * b[0] * c[2] \
           - a[0] * b[2] * c[1]

def sub(v0, v1):
    # v0 - v1
    return (v0[0] - v1[0], v0[1] - v1[1], v0[2] - v1[2])

# me
p0 = list(map(int, input().split()))

# enemy
p1 = list(map(int, input().split()))

# barrier
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

a = sub(p1, p0)
b = sub(A, B)
c = sub(A, C)
d = sub(A, p0)

denom = det(a, b, c)
lower = -0.0000001
upper = 1.0000001

if denom > 0:
    t = det(d, b, c) / denom
    u = det(a, d, c) / denom
    v = det(a, b, d) / denom

    if lower < t < upper and lower <= u <= upper and lower <= v <= upper and lower <= u + v <= upper:
        print('MISS')
    else:
        print('HIT')
else:
    print('HIT')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math

# refs
# https://shikousakugo.wordpress.com/2012/06/27/ray-intersection-2/

def det(a, b, c):
    return + a[0] * b[1] * c[2] \
           + a[2] * b[0] * c[1] \
           + a[1] * b[2] * c[0] \
           - a[2] * b[1] * c[0] \
           - a[1] * b[0] * c[2] \
           - a[0] * b[2] * c[1]

def sub(v0, v1):
    # v0 - v1
    return (v0[0] - v1[0], v0[1] - v1[1], v0[2] - v1[2])

# me
p0 = list(map(int, input().split()))

# enemy
p1 = list(map(int, input().split()))

# barrier
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

a = sub(p1, p0)
b = sub(A, B)
c = sub(A, C)
d = sub(A, p0)

denom = det(a, b, c)
lower = -0.0000001
upper = 1.0000001

if denom > 0:
    t = det(d, b, c) / denom
    u = det(a, d, c) / denom
    v = det(a, b, d) / denom

    if lower <= u <= upper and lower <= v <= upper and lower <= u + v <= upper:
        if t > 0:
            print('HIT')
        else:
            print('MISS')
    else:
        print('HIT')
else:
    print('HIT')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math

# refs
# https://shikousakugo.wordpress.com/2012/06/27/ray-intersection-2/

def det(a, b, c):
    return + a[0] * b[1] * c[2] \
           + a[2] * b[0] * c[1] \
           + a[1] * b[2] * c[0] \
           - a[2] * b[1] * c[0] \
           - a[1] * b[0] * c[2] \
           - a[0] * b[2] * c[1]

def sub(v0, v1):
    # v0 - v1
    return (v0[0] - v1[0], v0[1] - v1[1], v0[2] - v1[2])

# me
p0 = list(map(int, input().split()))

# enemy
p1 = list(map(int, input().split()))

# barrier
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

a = sub(p1, p0)
b = sub(A, B)
c = sub(A, C)
d = sub(A, p0)

denom = det(a, b, c)
lower = -0.0000001
upper = 1.0000001

if denom > 0:
    t = det(d, b, c) / denom
    u = det(a, d, c) / denom
    v = det(a, b, d) / denom

    if lower <= u <= upper and lower <= v <= upper and lower <= u + v <= upper:
        if t > 1:
            print('HIT')
        else:
            print('MISS')
    else:
        print('HIT')
else:
    print('HIT')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math

# refs
# https://shikousakugo.wordpress.com/2012/06/27/ray-intersection-2/

def det(a, b, c):
    return + a[0] * b[1] * c[2] \
           + a[2] * b[0] * c[1] \
           + a[1] * b[2] * c[0] \
           - a[2] * b[1] * c[0] \
           - a[1] * b[0] * c[2] \
           - a[0] * b[2] * c[1]

def sub(v0, v1):
    # v0 - v1
    return (v0[0] - v1[0], v0[1] - v1[1], v0[2] - v1[2])

# me
p0 = list(map(int, input().split()))

# enemy
p1 = list(map(int, input().split()))

# barrier
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

a = sub(p1, p0)
b = sub(A, B)
c = sub(A, C)
d = sub(A, p0)

denom = det(a, b, c)
lower = -0.0000001
upper = 1.0000001

if denom > 0:
    t = det(d, b, c) / denom
    u = det(a, d, c) / denom
    v = det(a, b, d) / denom
    
    # i am on barrier
    if lower < t < -lower:
        print('HIT')
    elif lower < t < upper and lower <= u <= upper and lower <= v <= upper and lower <= u + v <= upper:
        print('MISS')
    else:
        print('HIT')
else:
    print('HIT')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math

# refs
# https://shikousakugo.wordpress.com/2012/06/27/ray-intersection-2/

def det(a, b, c):
    return + a[0] * b[1] * c[2] \
           + a[2] * b[0] * c[1] \
           + a[1] * b[2] * c[0] \
           - a[2] * b[1] * c[0] \
           - a[1] * b[0] * c[2] \
           - a[0] * b[2] * c[1]

def sub(v0, v1):
    # v0 - v1
    return (v0[0] - v1[0], v0[1] - v1[1], v0[2] - v1[2])

# me
p0 = list(map(int, input().split()))

# enemy
p1 = list(map(int, input().split()))

# barrier
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

a = sub(p1, p0)
b = sub(A, B)
c = sub(A, C)
d = sub(A, p0)

denom = det(a, b, c)
lower = -0.0000001
upper = 1.0000001

if denom > 0:
    t = det(d, b, c) / denom
    u = det(a, d, c) / denom
    v = det(a, b, d) / denom

    # i am on barrier
    if lower < t < -lower:
        print('HIT')
    elif t > 1:
        print('HIT')
    elif lower < t < upper and lower <= u <= upper and lower <= v <= upper and lower <= u + v <= upper:
        print('MISS')
    else:
        print('HIT')
else:
    print('HIT')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math

# refs
# https://shikousakugo.wordpress.com/2012/06/27/ray-intersection-2/

def det(a, b, c):
    return + a[0] * b[1] * c[2] \
           + a[2] * b[0] * c[1] \
           + a[1] * b[2] * c[0] \
           - a[2] * b[1] * c[0] \
           - a[1] * b[0] * c[2] \
           - a[0] * b[2] * c[1]

def sub(v0, v1):
    # v0 - v1
    return (v0[0] - v1[0], v0[1] - v1[1], v0[2] - v1[2])

# me
p0 = list(map(int, input().split()))

# enemy
p1 = list(map(int, input().split()))

# barrier
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

a = sub(p1, p0)
b = sub(A, B)
c = sub(A, C)
d = sub(A, p0)

denom = det(a, b, c)
lower = -0.0000001
upper = 1.0000001

if denom > 0:
    t = det(d, b, c) / denom
    u = det(a, d, c) / denom
    v = det(a, b, d) / denom

    # i am on barrier
    if lower < t < -lower:
        print('HIT')
    elif t > 1:
        print('HIT')
    elif t < 0:
        print('MISS')
    elif lower < t < upper and lower <= u <= upper and lower <= v <= upper and lower <= u + v <= upper:
        print('MISS')
    else:
        print('HIT')
else:
    print('HIT')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math

# refs
# https://shikousakugo.wordpress.com/2012/06/27/ray-intersection-2/

def det(a, b, c):
    return + a[0] * b[1] * c[2] \
           + a[2] * b[0] * c[1] \
           + a[1] * b[2] * c[0] \
           - a[2] * b[1] * c[0] \
           - a[1] * b[0] * c[2] \
           - a[0] * b[2] * c[1]

def sub(v0, v1):
    # v0 - v1
    return (v0[0] - v1[0], v0[1] - v1[1], v0[2] - v1[2])

# me
p0 = list(map(int, input().split()))

# enemy
p1 = list(map(int, input().split()))

# barrier
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

a = sub(p1, p0)
b = sub(A, B)
c = sub(A, C)
d = sub(A, p0)

denom = det(a, b, c)
lower = -0.0000001
upper = 1.0000001

if denom > 0:
    t = det(d, b, c) / denom
    u = det(a, d, c) / denom
    v = det(a, b, d) / denom

    # i am on barrier
    if lower < t < -lower:
        print('HIT')
    elif t > 1:
        print('HIT')
    elif t < lower:
        print('MISS')
    elif lower < t < upper and lower <= u <= upper and lower <= v <= upper and lower <= u + v <= upper:
        print('MISS')
    else:
        print('HIT')
else:
    print('HIT')