Problem:


  MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});

A Point in a Triangle

There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.

Write a program which prints "YES" if a point $P$ $(x_p, y_p)$ is in the triangle and "NO" if not.

Input

Input consists of several datasets. Each dataset consists of:

$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$ $x_p$ $y_p$

All the input are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.

Constraints

You can assume that:

$ -100 \leq x_1, y_1, x_2, y_2, x_3, y_3, x_p, y_p \leq 100$

1.0 $\leq$ Length of each side of a tringle

0.001 $\leq$ Distance between $P$ and each side of a triangle

Output

For each dataset, print "YES" or "NO" in a line.

Sample Input

0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0

Output for the Sample Input

YES
NO



Sample input:
0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5
0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0


Sample output:
YES
NO

Submission status: Wrong Answer

Solution code:
# coding: utf-8
#Problem Name: A Point in a Triangle
#ID: tabris
#Mail: t123037@kaiyodai.ac.jp

def check(p1,p2):
    global xp,yp
    if p1[0] == p2[0]:
        return False
    elif p1[1] == p2[1]:
        if yp > p1[1]:
            return True
        else:
            return False
    else:
        a = (p2[1]-p1[1])/(p2[0]-p1[0])
        b = p1[1] - a*p1[0]
        if yp > a*xp+b:
            return True
        else:
            return False

while True:
    try:
        x1,y1,x2,y2,x3,y3,xp,yp = map(float,raw_input().split(' '))
        upper = [0]*3
        upper[0] = check([x1,y1],[x2,y2])
        upper[1] = check([x2,y2],[x3,y3])
        upper[2] = check([x3,y3],[x1,y1])
        if True in upper and False in upper:
            print 'YES'
        else:
            print 'NO'
    except:
        break

Submission status: Wrong Answer

Solution code:
# coding: utf-8
#Problem Name: A Point in a Triangle
#ID: tabris
#Mail: t123037@kaiyodai.ac.jp

def check(p1,p2):
    global xp,yp
    if p1[0] == p2[0]:
        return False
    elif p1[1] == p2[1]:
        if yp > p1[1]:
            return True
        else:
            return False
    else:
        a = (p2[1]-p1[1])/(p2[0]-p1[0])
        b = p1[1] - a*p1[0]
        if yp > a*xp+b:
            return True
        else:
            return False

while True:
    try:
        x1,y1,x2,y2,x3,y3,xp,yp = map(float,raw_input().split(' '))
        upper = [0]*3
        upper[0] = check([x1,y1],[x2,y2])
        upper[1] = check([x2,y2],[x3,y3])
        upper[2] = check([x3,y3],[x1,y1])
        if max(y1,y2,y3) > yp > min(y1,y2,y3) and max(x1,x2,x3) > xp > min(x1,x2,x3) and True in upper and False in upper:
            print 'YES'
        else:
            print 'NO'
    except:
        break

Submission status: Wrong Answer

Solution code:
while True:
	try:
		x1, y1, x2, y2, x3, y3, xp, yp = map(float, raw_input().strip().split(' '))
		x = sorted([x1, x2, x3, xp])
		y = sorted([y1, y2, y3, yp])
		if x.index(xp) > 0 and x.index(xp) < 3 and y.index(yp) > 0 and y.index(yp) < 3:
			print "YES"
		else:
			print "NO"
	except EOFError:
		break

Submission status: Wrong Answer

Solution code:
import sys
def area(x1,y1,x2,y2,x3,y3):
    return abs((x1*(y2-y3) + x2*(y3-y1)+ x3*(y1-y2))/2.0)
for line in sys.stdin.readlines():
    x1, y1, x2, y2, x3, y3, xp, yp=map(float,line.split())
    a1=area(x1,y1,x2,y2,xp,yp)
    a2=area(x3,y3,x2,y2,xp,yp)
    a3=area(x1,y1,x3,y3,xp,yp)
    a=area(x1,y1,x2,y2,x3,y3)
    if(a==(a1+a2+a3)):
        print("YES")
    else:
        print("NO")

Submission status: Wrong Answer

Solution code:
#encoding=utf-8
import sys
import math

def inp():
    for i in sys.stdin:
        x1,y1,x2,y2,x3,y3,xp,yp = map(float, i.split())
        p = ((y1 - y3)*(y1**2 - y1**2 + x1**2 - x2**2) - (y1 - y2)*(y1**2 - y3**2 + x1**2 - x3**2))/(2*(y1 - y3)*(x1 - x2) - 2*(y1 - y2)*(x1 - x3))
        q = ((x1 - x3)*(x1**2 - x2**2 + y1**2 - y2**2) - (x1 - x2)*(x1**2 - x3**2 + y1**2 - y3**2))/(2*(x1 - x3)*(y1 - y2) - 2*(x1 - x2)*(y1 - y3))
        a,b = rennritu(x1,y1,x2,y2)
        c1 = hantei(a,b,p,q,xp,yp)
        a,b = rennritu(x2,y2,x3,y3)
        c2 = hantei(a,b,p,q,xp,yp)
        a,b = rennritu(x3,y3,x1,y1)
        c3 = hantei(a,b,p,q,xp,yp)
        if c1 == c2 == c3:
            print "Yes"
        else:
            print "No"

def rennritu(x1,y1,x2,y2):
    if x1 == 0:
        if y1 == 0:
            return 1,1
        else:
            return 0,y1
    elif y1 == 0:
        return x1,0
    elif x2 == 0:
        if y2 == 0:
            return 0,0
        else:
            return 0,y2
    elif y2 == 0:
        return x2,0

    else:
        a = (y1 - y2)/(x1 - x2)
        b = y1 - (a*x1)
    return a,b

def hantei(a,b,p,q,xp,yp):
    z1 = niji(a,b,p,q)
    z2 = niji(a,b,xp,yp)
    if z1 == z2:
        return 1
    else:
        return 0

def niji(a,b,x,y):
    if y < a*x + b:
        return 0
    else:
        return 1

if __name__ == "__main__":
    inp()

Submission status: Wrong Answer

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

import sys
import math

class Point_Class():
    def __init__(self, x, y):
        self.x = x
        self.y = y

def isIn(p1, p2, p3, pp):
    a = p2.y-p1.y
    b = p2.x-p1.x
    c = p2.x*p1.y-p1.x*p2.y
    d = p3.y-p2.y
    e = p3.x-p2.x
    f = p3.x*p2.y-p2.x*p3.y
    g = p1.y-p3.y
    h = p1.x-p3.x
    i = p1.x*p3.y-p1.x*p3.y
    left_12 = left_23 = left_31 = True
    if (a*pp.x-b*pp.y+c)*(a*p3.x-b*p3.y+c) < 0:
        left_12 = False
    if (d*pp.x-e*pp.y+f)*(d*p3.x-e*p3.y+f) < 0:
        left_23 = False
    if (g*pp.x-h*pp.y+i)*(g*p3.x-h*p3.y+i) < 0:
        left_31 = False
    if left_12 == left_23 and left_23 == left_31:
        return True
    else:
        return False

for line in sys.stdin:
    x1, y1, x2, y2, x3, y3, xp, yp = map(float, line.split())
    p1 = Point_Class(x1, y1)
    p2 = Point_Class(x2, y2)
    p3 = Point_Class(x3, y3)
    pp = Point_Class(xp, yp)
    print "YES" if isIn(p1, p2, p3, pp) else "NO"

Submission status: Wrong Answer

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

import sys
import math

class Point_Class():
    def __init__(self, x, y):
        self.x = x
        self.y = y

def isIn(p1, p2, p3, pp):
    a = p2.y-p1.y
    b = p2.x-p1.x
    c = p2.x*p1.y-p1.x*p2.y
    d = p3.y-p2.y
    e = p3.x-p2.x
    f = p3.x*p2.y-p2.x*p3.y
    g = p1.y-p3.y
    h = p1.x-p3.x
    i = p1.x*p3.y-p1.x*p3.y
    left_12 = left_23 = left_31 = True
    if (a*pp.x-b*pp.y+c)*(a*p3.x-b*p3.y+c) < 0:
        left_12 = False
    if (d*pp.x-e*pp.y+f)*(d*p1.x-e*p1.y+f) < 0:
        left_23 = False
    if (g*pp.x-h*pp.y+i)*(g*p2.x-h*p2.y+i) < 0:
        left_31 = False
    print left_12, left_23, left_31
    if left_12 == left_23 == left_31:
        return True
    else:
        return False

for line in sys.stdin:
    x1, y1, x2, y2, x3, y3, xp, yp = map(float, line.split())
    p1 = Point_Class(x1, y1)
    p2 = Point_Class(x2, y2)
    p3 = Point_Class(x3, y3)
    pp = Point_Class(xp, yp)
    print "YES" if isIn(p1, p2, p3, pp) else "NO"

Submission status: Wrong Answer

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

import sys
import math

class Point_Class():
    def __init__(self, x, y):
        self.x = x
        self.y = y

def isIn(p1, p2, p3, pp):
    a = p2.y-p1.y
    b = p2.x-p1.x
    c = p2.x*p1.y-p1.x*p2.y
    d = p3.y-p2.y
    e = p3.x-p2.x
    f = p3.x*p2.y-p2.x*p3.y
    g = p1.y-p3.y
    h = p1.x-p3.x
    i = p1.x*p3.y-p1.x*p3.y
    left_12 = left_23 = left_31 = True
    if (a*pp.x-b*pp.y+c)*(a*p3.x-b*p3.y+c) < 0:
        left_12 = False
    if (d*pp.x-e*pp.y+f)*(d*p1.x-e*p1.y+f) < 0:
        left_23 = False
    if (g*pp.x-h*pp.y+i)*(g*p2.x-h*p2.y+i) < 0:
        left_31 = False
    if left_12 == left_23 == left_31:
        return True
    else:
        return False

for line in sys.stdin:
    x1, y1, x2, y2, x3, y3, xp, yp = map(float, line.split())
    p1 = Point_Class(x1, y1)
    p2 = Point_Class(x2, y2)
    p3 = Point_Class(x3, y3)
    pp = Point_Class(xp, yp)
    print "YES" if isIn(p1, p2, p3, pp) else "NO"

Submission status: Wrong Answer

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

import sys
import math

class Point_Class():
    def __init__(self, x, y):
        self.x = x
        self.y = y

def isIn(p1, p2, p3, pp):
    a = p2.y-p1.y
    b = p2.x-p1.x
    c = p2.x*p1.y-p1.x*p2.y
    d = p3.y-p2.y
    e = p3.x-p2.x
    f = p3.x*p2.y-p2.x*p3.y
    g = p1.y-p3.y
    h = p1.x-p3.x
    i = p1.x*p3.y-p1.x*p3.y
    if (a*pp.x-b*pp.y+c)*(a*p3.x-b*p3.y+c) < 0:
        return False
    if (d*pp.x-e*pp.y+f)*(d*p1.x-e*p1.y+f) < 0:
        return False
    if (g*pp.x-h*pp.y+i)*(g*p2.x-h*p2.y+i) < 0:
        return False
    return True


for line in sys.stdin:
    x1, y1, x2, y2, x3, y3, xp, yp = map(float, line.split())
    p1 = Point_Class(x1, y1)
    p2 = Point_Class(x2, y2)
    p3 = Point_Class(x3, y3)
    pp = Point_Class(xp, yp)
    print "YES" if isIn(p1, p2, p3, pp) else "NO"

Submission status: Wrong Answer

Solution code:
import sys

def crossMulti(p1, p2):
    return p1[0] * p2[1] - p1[1] * p2[0]
           
lines = sys.stdin.readlines()
for line in lines:
    Zd = []
    x1, y1, x2, y2, x3, y3, xp, yp = map(float, line.split())
    Ps = [(x2-x1, y2-y1),(x3-x2, y3-y2),(x1-x3, y1-y3)]
    Px = [(xp-x1, yp-y1),(xp-x2, yp-y2),(xp-x3, yp-y3)]
    for p in range(3):
        Zd.append(crossMulti(Ps[p], Px[p]))
    Zd = [x > 0 for x in Zd]

    if (Zd[0] and Zd[1] and Zd[2]) or not(Zd[0] or Zd[1] or Zd[2]):
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
import math


class Triangle:
    def __init__(self, x1, y1, x2, y2, x3, y3):
        self.x1 = x1
        self.x2 = x2
        self.x3 = x3
        self.y1 = y1
        self.y2 = y2
        self.y3 = y3
        self.a = math.sqrt((x1-x2) ** 2 + (y1 - y2) ** 2)
        self.b = math.sqrt((x2-x3) ** 2 + (y2 - y3) ** 2)
        self.c = math.sqrt((x1-x3) ** 2 + (y1 - y3) ** 2)

    def get_acos_a(self):
        val = (-self.a ** 2 + self.b ** 2 + self.c ** 2) / (2 * self.b * self.c)
        return math.acos(val)


while(1):

    try:
        x1, y1, x2, y2, x3, y3, xp, yp = list(map(float, input().split()))
        t1 = Triangle(x1, y1, x2, y2, xp, yp)
        t2 = Triangle(x2, y2, x3, y3, xp, yp)
        t3 = Triangle(x3, y3, x1, y1, xp, yp)

        if 6.283 <= t1.get_acos_a() + t2.get_acos_a() + t3.get_acos_a() <= 6.284:
            print("YES")
        else:
            print("NO")

    except:
        break

Submission status: Wrong Answer

Solution code:
out=[]
while True:
	try:
		k=list(map(float,input().split(" ")))
	except:
		break

	O_x,O_y=k[0],k[1]
	A_x,A_y=k[2],k[3]
	B_x,B_y=k[4],k[5]
	P_x,P_y=k[6],k[7]

# P in triangle OAB
# iff  s+t<1 and s>0 and t>0 (OP=sOA+tOB)

	OA=(A_x-O_x,A_y-O_y)
	OB=(B_x-O_x,B_y-O_y)
	OP=(P_x-O_x,P_y-O_y)

	keisuu=1/( OA[0]*OB[1] - OA[1]*OB[0] )

	s=keisuu*(  OB[1]*OP[0]-OB[0]*OP[1] )
	t=keisuu*( -OA[1]*OP[0]+OA[0]*OP[1] )

	if s>0 and t>0 and s+t>0:
		out.append("YES")
	else:
		out.append("NO")

for i in out:
	print(i)

Submission status: Wrong Answer

Solution code:
def Cramer(a11, a12, a13, a21, a22, a23):
	den = a11 * a22 - a12 * a21
	return (a13 * a22 - a12 * a23) / den, (a11 * a23 - a13 * a21) / den

while True:
	try:
		x1, y1, x2, y2, x3, y3, xp, yp = [eval(item) for item in input().split()]
		u, v = Cramer(x3 - x1, x2 - x1, xp - x1, y3 - y1, y2 - y1, yp - y1)
		print('YES' if u >= 0.0 and v >= 0.0 and u + v - 1.0 < 1e10 else 'NO')
	except EOFError:
		break

Submission status: Wrong Answer

Solution code:
def Cramer(a11, a12, a13, a21, a22, a23):
	den = a11 * a22 - a12 * a21
	return (a13 * a22 - a12 * a23) / den, (a11 * a23 - a13 * a21) / den

while True:
	try:
		x1, y1, x2, y2, x3, y3, xp, yp = [eval(item) for item in input().split()]
		u, v = Cramer(x3 - x1, x2 - x1, xp - x1, y3 - y1, y2 - y1, yp - y1)
		print('YES' if u >= 0.0 and v >= 0.0 and abs(u + v - 1.0) < 1e10 else 'NO')
	except EOFError:
		break

Submission status: Wrong Answer

Solution code:
import math
while True:
    try:
        x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split())
        x = [x1, x3, x3, x1]
        y = [y1, y2, y3, y1]
        x = list(map(lambda x:x-xp, x))
        y = list(map(lambda y:y-yp, y))
        cos = lambda a1,a2,b1,b2:(a1*b1+a2*b2)/((a1**2+a2**2)**0.5*(b1**2+b2**2)**0.5)
        if sum(math.acos(cos(x[i], y[i], x[i+1], y[i+1])) for i in range(3)) < math.pi:
            print('NO')
        else:
            print('YES')
    except:
        break

Submission status: Wrong Answer

Solution code:
import math
while True:
    try:
        x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split())
        x = [x1, x3, x3, x1]
        y = [y1, y2, y3, y1]
        x = list(map(lambda x:x-xp, x))
        y = list(map(lambda y:y-yp, y))
        cos = lambda a1,a2,b1,b2:(a1*b1+a2*b2)/((a1**2+a2**2)**0.5*(b1**2+b2**2)**0.5)
        if sum(math.acos(cos(x[i], y[i], x[i+1], y[i+1])) for i in range(3)) < math.pi-1e-5:
            print('NO')
        else:
            print('YES')
    except:
        break

Submission status: Wrong Answer

Solution code:
import math
while True:
    try:
        x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split())
        x = [x1, x3, x3, x1]
        y = [y1, y2, y3, y1]
        x = list(map(lambda x:x-xp, x))
        y = list(map(lambda y:y-yp, y))
        cos = lambda a1,a2,b1,b2:(a1*b1+a2*b2)/((a1**2+a2**2)**0.5*(b1**2+b2**2)**0.5)
        if sum(math.acos(cos(x[i], y[i], x[i+1], y[i+1])) for i in range(3)) < 2 * math.pi:
            print('NO')
        else:
            print('YES')
    except:
        break

Submission status: Wrong Answer

Solution code:
import math
while True:
    try:
        x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split())
        x = [x1, x3, x3, x1]
        y = [y1, y2, y3, y1]
        x = list(map(lambda x:x-xp, x))
        y = list(map(lambda y:y-yp, y))
        cos = lambda a1,a2,b1,b2:(a1*b1+a2*b2)/((a1**2+a2**2)**0.5*(b1**2+b2**2)**0.5)
        if sum(math.acos(cos(x[i], y[i], x[i+1], y[i+1])) for i in range(3)) < 2 * math.pi - 1e-5:
            print('NO')
        else:
            print('YES')
    except:
        break

Submission status: Wrong Answer

Solution code:
import math
while True:
    try:
        x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split())
        x = [x1, x3, x3, x1]
        y = [y1, y2, y3, y1]
        x = list(map(lambda x:x-xp, x))
        y = list(map(lambda y:y-yp, y))
        cos = lambda a1,a2,b1,b2:(a1*b1+a2*b2)/((a1**2+a2**2)**0.5*(b1**2+b2**2)**0.5)
        if sum(math.acos(cos(x[i], y[i], x[i+1], y[i+1])) for i in range(3)) < 2 * math.pi - 1e-5:
            print('NO')
            print(sum(math.acos(cos(x[i], y[i], x[i+1], y[i+1])) for i in range(3)))
        else:
            print('YES')
            print(sum(math.acos(cos(x[i], y[i], x[i+1], y[i+1])) for i in range(3)))
    except:
        break

Submission status: Wrong Answer

Solution code:
import math
while True:
    try:
        x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split())
        x = [x1, x3, x3, x1]
        y = [y1, y2, y3, y1]
        x = list(map(lambda x:x-xp, x))
        y = list(map(lambda y:y-yp, y))
        cos = lambda a1,a2,b1,b2:(a1*b1+a2*b2)/((a1**2+a2**2)**0.5*(b1**2+b2**2)**0.5)
        if sum(math.acos(cos(x[i], y[i], x[i+1], y[i+1])) for i in range(3)) <= 2 * math.pi:
            print('NO')
        else:
            print('YES')
    except:
        break

Submission status: Wrong Answer

Solution code:
import math
while True:
    try:
        x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split())
        x = [x1, x3, x3, x1]
        y = [y1, y2, y3, y1]
        x = list(map(lambda x:x-xp, x))
        y = list(map(lambda y:y-yp, y))
        cos = lambda a1,a2,b1,b2:(a1*b1+a2*b2)/((a1**2+a2**2)**0.5*(b1**2+b2**2)**0.5)
        if sum(math.acos(cos(x[i], y[i], x[i+1], y[i+1])) for i in range(3)) < 2 * math.pi - 1e-3:
            print('NO')
        else:
            print('YES')
    except:
        break

Submission status: Wrong Answer

Solution code:
import math
while True:
    try:
        x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split())
        x = [x1, x3, x3, x1]
        y = [y1, y2, y3, y1]
        x = list(map(lambda x:x-xp, x))
        y = list(map(lambda y:y-yp, y))
        cos = lambda a1,a2,b1,b2:max(min((a1*b1+a2*b2)/((a1**2+a2**2)**0.5*(b1**2+b2**2)**0.5),1),-1)
        if sum(math.acos(cos(x[i], y[i], x[i+1], y[i+1])) for i in range(3)) < 2 * math.pi:
            print('NO')
        else:
            print('YES')
    except:
        break

Submission status: Wrong Answer

Solution code:
import math
while True:
    try:
        x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split())
        x = [x1, x3, x3, x1]
        y = [y1, y2, y3, y1]
        x = list(map(lambda x:x-xp, x))
        y = list(map(lambda y:y-yp, y))
        cos = lambda a1,a2,b1,b2:max(min((a1*b1+a2*b2)/((a1**2+a2**2)**0.5*(b1**2+b2**2)**0.5),1),-1)
        if sum(math.acos(cos(x[i], y[i], x[i+1], y[i+1])) for i in range(3)) < 2 * math.pi - 1e-6:
            print('NO')
        else:
            print('YES')
    except:
        break

Submission status: Wrong Answer

Solution code:
import math
while True:
    try:
        x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split())
    except:
        break
    x = [x1, x3, x3, x1]
    y = [y1, y2, y3, y1]
    x = list(map(lambda x: x - xp, x))
    y = list(map(lambda y: y - yp, y))
    s = lambda a1, a2, b1, b2: abs(a1 * b2 - a2 * b1)
    if sum(s(x[i], y[i], x[i + 1], y[i + 1]) for i in range(3)) == s(x[1] - x[0], y[1] - y[0], x[2] - x[0], y[2] - y[0]):
        print('YES')
    else:
        print('NO')

Submission status: Wrong Answer

Solution code:
import math
while True:
    try:
        x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split())
    except:
        break
    x = [x1, x3, x3, x1]
    y = [y1, y2, y3, y1]
    x = list(map(lambda x: x - xp, x))
    y = list(map(lambda y: y - yp, y))
    s = lambda a1, a2, b1, b2: abs(a1 * b2 - a2 * b1)
    if abs(sum(s(x[i], y[i], x[i + 1], y[i + 1]) for i in range(3)) - s(x[1] - x[0], y[1] - y[0], x[2] - x[0], y[2] - y[0])) < 1e-10:
        print('YES')
    else:
        print('NO')

Submission status: Wrong Answer

Solution code:
import math
while True:
    try:
        x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split())
    except:
        break
    x = [x1, x3, x3, x1]
    y = [y1, y2, y3, y1]
    x = list(map(lambda x: x - xp, x))
    y = list(map(lambda y: y - yp, y))
    s = lambda a1, a2, b1, b2: abs(a1 * b2 - a2 * b1)
    if abs(sum(s(x[i], y[i], x[i + 1], y[i + 1]) for i in range(3)) - s(x[1] - x[0], y[1] - y[0], x[2] - x[0], y[2] - y[0])) < 1e-15:
        print('YES')
    else:
        print('NO')

Submission status: Wrong Answer

Solution code:
import math
while True:
    try:
        x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split())
    except:
        break
    x = [x1, x3, x3, x1]
    y = [y1, y2, y3, y1]
    x = list(map(lambda x: x - xp, x))
    y = list(map(lambda y: y - yp, y))
    s = lambda a1, a2, b1, b2: abs(a1 * b2 - a2 * b1)
    if abs(sum(s(x[i], y[i], x[i + 1], y[i + 1]) for i in range(3)) - s(x[1] - x[0], y[1] - y[0], x[2] - x[0], y[2] - y[0])) < 1e-5:
        print('YES')
    else:
        print('NO')

Submission status: Wrong Answer

Solution code:
import math
while True:
    try:
        x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split())
    except:
        break
    x = [x1, x3, x3, x1]
    y = [y1, y2, y3, y1]
    x = list(map(lambda x: x - xp, x))
    y = list(map(lambda y: y - yp, y))
    s = lambda a1, a2, b1, b2: abs(a1 * b2 - a2 * b1)
    if abs(sum(s(x[i], y[i], x[i + 1], y[i + 1]) for i in range(3)) - s(x[1] - x[0], y[1] - y[0], x[2] - x[0], y[2] - y[0])) < .00001:
        print('YES')
    else:
        print('NO')

Submission status: Wrong Answer

Solution code:
class point:
    def __init__(self, x, y):
        self.x = x
        self.y = y
    def sub(self, p):
        return point(self.x - p.x, self.y - p.y)

while 1:
    try:
        x1, y1, x2, y2, x3, y3, xp, yp = map(float, raw_input().split())
        A = point(x1, y1)
        B = point(x2, y2)
        C = point(x3, y3)
        P = point(xp, yp)

        AB = B.sub(A)
        BP = P.sub(B)
        BC = C.sub(B)
        CP = P.sub(C)
        CA = A.sub(C)
        AP = P.sub(A)

        c1 = AB.x * BP.y - AB.y * BP.x
        c2 = BC.x * CP.y - BC.y * CP.x
        c3 = CA.x * AP.y - CA.y * AP.x

        if((c1 > 0) and (c2 > 0) and (c3 > 0) or (c1 < 0) and (c2 < 0) and (c3 < 0)): print YES
        else: print NO
    except:
        break

Submission status: Wrong Answer

Solution code:
class vector(object):
    def __init__(self,a,b):
        self.x=b.x-a.x
        self.y=b.y-a.y
    @staticmethod
    def cross_product(a,b):
        return a.x*b.y-a.y*b.x
class vertex(object):
    def __init__(self,a):
        self.x=a[0]
        self.y=a[1]
class circle(object):
    def __init__(self,p,r):
        self.px=p.x
        self.py=p.y
        self.r=r
class triangle(object):
    def __init__(self,a,b,c):
        self.a=a
        self.b=b
        self.c=c
        import math
        self.ab=math.sqrt((self.a.x-self.b.x)**2+(self.a.y-self.b.y)**2)
        self.bc=math.sqrt((self.b.x-self.c.x)**2+(self.b.y-self.c.y)**2)
        self.ca=math.sqrt((self.c.x-self.a.x)**2+(self.c.y-self.a.y)**2)
        c=self.ab
        a=self.bc
        b=self.ca
        self.cosA=(b**2+c**2-a**2)/(2*b*c)
        self.cosB=(a**2+c**2-b**2)/(2*a*c)
        self.cosC=(b**2+a**2-c**2)/(2*b*a)
        self.sinA=math.sqrt(1-self.cosA**2)
        self.sinB=math.sqrt(1-self.cosB**2)
        self.sinC=math.sqrt(1-self.cosC**2)
        self.sin2A=2*self.sinA*self.cosA
        self.sin2B=2*self.sinB*self.cosB
        self.sin2C=2*self.sinC*self.cosC
    def area(self):
        import math
        s=(self.ab+self.bc+self.ca)/2
        S=math.sqrt(s*(s-self.ab)*(s-self.bc)*(s-self.ca))
        return S
    def circumscribed(self):
        R=self.ab/(2*self.sinC)
        px=(self.sin2A*self.a.x+self.sin2B*self.b.x+self.sin2C*self.c.x)/(self.sin2A+self.sin2B+self.sin2C)
        py=(self.sin2A*self.a.y+self.sin2B*self.b.y+self.sin2C*self.c.y)/(self.sin2A+self.sin2B+self.sin2C)
        px=round(px,3)
        py=round(py,3)
        R=round(R,3)
        p=vertex((px,py))
        return circle(p,R)
    def isin(self,p):
        AB=vector(self.a,self.b)
        BC=vector(self.b,self.c)
        CA=vector(self.c,self.a)
        AP=vector(self.a,p)
        BP=vector(self.b,p)
        CP=vector(self.c,p)
        if (vector.cross_product(AB,AP)>0 and vector.cross_product(BC,BP)>0 and vector.cross_product(CA,CP)>0)or(vector.cross_product(AB,AP)<0 and vector.cross_product(BC,BP)<0 and vector.cross_product(CA,CP)<0):
            return 'Yes'
        else:return 'No'
A=[]
B=[]
C=[]
p=[]
import sys
for line in sys.stdin:
    a,b,c,d,e,f,g,h=list(map(float,line.split()))
    A.append(vertex((a,b)))
    B.append(vertex((c,d)))
    C.append(vertex((e,f)))
    p.append(vertex((g,h)))
for i in range(len(A)):
    Triangle=triangle(A[i],B[i],C[i])
    print(Triangle.isin(p[i]))

Submission status: Wrong Answer

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

import sys
import math

def norm(x1,y1,x2,y2):
    r = math.sqrt((x2 - x1)**2 + (y2 - y1)**2)
    return r

def judge(x1,y1,x2,y2,x3,y3,xp,yp):
    r1 = norm(x1,y1,x2,y2)
    r2 = norm(x2,y2,x3,y3)
    r3 = norm(x3,y3,x1,y1)

    d1 = norm(xp,yp,x1,y1)
    d2 = norm(xp,yp,x2,y2)
    d3 = norm(xp,yp,x3,y3)

    if d1 > r1 or d1 > r3:
        print('NO')
    elif d2 > r1 or d2 > r2:
        print('NO')
    elif d3 > r3 or d3 > r2:
        print('NO')
    else:
        print('YES')

array = []
for i in sys.stdin:
    array.append(i)

for i in range(len(array)):
    tmp = array[i]
    x1,y1,x2,y2,x3,y3,xp,yp = map(float,tmp.split(' '))
    judge(x1,y1,x2,y2,x3,y3,xp,yp)

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
import sys
import math

def norm(x1,y1,x2,y2):
    r = math.sqrt((x2 - x1)**2 + (y2 - y1)**2)
    return r

def judge(x1,y1,x2,y2,x3,y3,xp,yp):
    r1 = norm(x1,y1,x2,y2)
    r2 = norm(x2,y2,x3,y3)
    r3 = norm(x3,y3,x1,y1)

    d1 = norm(xp,yp,x1,y1)
    d2 = norm(xp,yp,x2,y2)
    d3 = norm(xp,yp,x3,y3)

    if d1 > r1 or d1 > r3:
        print('NO')
    elif d2 > r1 or d2 > r2:
        print('NO')
    elif d3 > r3 or d3 > r2:
        print('NO')
    else:
        print('YES')

array = []
for i in sys.stdin:
    array.append(i)

for i in range(len(array)):
    tmp = array[i]
    x1,y1,x2,y2,x3,y3,xp,yp = map(float,tmp.split(' '))
    judge(x1,y1,x2,y2,x3,y3,xp,yp)

Submission status: Wrong Answer

Solution code:
import math

def tri(x1, y1, x2, y2, x3, y3):
    return math.fabs((x2-x1)*(y3-y1) - (y2-y1)*(x3-x1)) / 2

while True:
    try:
        x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split())
    except:
        break
    abc = tri(x1, y1, x2, y2, x3, y3)
    abp = tri(x1, y1, x2, y2, xp, yp)
    acp = tri(x1, y1, x3, y3, xp, yp)
    bcp = tri(x2, y2, x3, y3, xp, yp)
    print("YES" if abc>=abp+acp+bcp else "NO")

Submission status: Wrong Answer

Solution code:
import sys

lines = str(sys.stdin.read()).strip().split("\n")
for line in lines:
	data = line.split(" ")
	x1 = data[0]
	y1 = data[1]
	x2 = data[2]
	y2 = data[3]
	x3 = data[4]
	y3 = data[5]
	xp = data[6]
	yp = data[7]
	if xp > min(x1, x2, x3) and xp < max(x1, x2, x3) and yp > min(y1, y2, y3) and yp < max(y1, y2, y3):
		print("YES")
	else:
		print("NO")

Submission status: Wrong Answer

Solution code:
import sys

lines = str(sys.stdin.read()).strip().split("\n")
for line in lines:
	data = line.split(" ")
	x1 = float(data[0])
	y1 = float(data[1])
	x2 = float(data[2])
	y2 = float(data[3])
	x3 = float(data[4])
	y3 = float(data[5])
	xp = float(data[6])
	yp = float(data[7])
	if xp > min(x1, x2, x3) and xp < max(x1, x2, x3) and yp > min(y1, y2, y3) and yp < max(y1, y2, y3):
		print("YES")
	else:
		print("NO")

Submission status: Wrong Answer

Solution code:
try:
    while True:
        li = [float(x) for x in input().split()]
        lix = [li[i] for i in range(6) if i % 2 == 0]
        liy = [li[i] for i in range(6) if i % 2 != 0]
        x, y = li[6], li[7]
        if min(lix) < x < max(lix) and min(liy) < y < max(liy):
            print("YES")
        else:
            print("NO")
except EOFError:
    pass

Submission status: Wrong Answer

Solution code:
try:
    while True:
        li = [float(x) for x in input().split()]
        lix = [li[i] for i in range(6) if i % 2 == 0]
        liy = [li[i] for i in range(6) if i % 2 != 0]
        x, y = li[6], li[7]
        if min(lix) <= x <= max(lix) and min(liy) <= y <= max(liy):
            print("YES")
        else:
            print("NO")
except EOFError:
    pass

Submission status: Wrong Answer

Solution code:
try:
    while True:
        li = [float(x) for x in input().split()]
        if li:
            lix = [li[i] for i in range(6) if i % 2 == 0]
            liy = [li[i] for i in range(6) if i % 2 != 0]
            x, y = li[6], li[7]
            if min(lix) <= x <= max(lix) and min(liy) <= y <= max(liy):
                print("YES")
            else:
                print("NO")
except EOFError:
    pass

Submission status: Wrong Answer

Solution code:
try:
    while True:
        li = [float(x) for x in input().split()]
        if li:
            lix = [li[i] for i in range(6) if i % 2 == 0]
            liy = [li[i] for i in range(6) if i % 2 != 0]
            x, y = li[6], li[7]
            if min(lix) < x < max(lix) and min(liy) < y < max(liy):
                print("YES")
            else:
                print("NO")
except EOFError:
    pass

Submission status: Wrong Answer

Solution code:
while True:
 try:
  x1,y1,x2,y2,x3,y3,xp,yp=map(float,input().split())
  if xp<0 or yp<0:
    print('No')
  else:
    print('Yes')
 except: break

Submission status: Wrong Answer

Solution code:
length=[float(0) for i in range(3)]
while 1:
    try:
      x1,y1,x2,y2,x3,y3,x4,y4=[float(i) for i in input().split( )]
      len1=(x1-x2)**2+(y1-y2)**2
      len2=(x2-x3)**2+(y2-y3)**2
      len3=(x3-x1)**2+(y3-y1)**2
      length[0]=(x1-x4)**2+(y1-y4)**2
      length[1]=(x2-x4)**2+(y2-y4)**2
      length[2]=(x3-x4)**2+(y3-y4)**2
      if ((max(length)>len1)and(max(length)>len2)and(max(length)>len3)):
          print("NO")
      else:
          print("YES")
    except EOFError:
        break

Submission status: Wrong Answer

Solution code:
import math
import sys


def get_triangle_area(x1, y1, x2, y2, x3, y3):
    l1 = math.sqrt(abs(x1-x2)**2+abs(y1-y2)**2)
    l2 = math.sqrt(abs(x2-x3)**2+abs(y2-y3)**2)
    l3 = math.sqrt(abs(x3-x1)**2+abs(y3-y1)**2)
    s = (l1+l2+l3)/2
    return math.sqrt(s*(s-l1)*(s-l2)*(s-l3))


for l in sys.stdin:
    x1, y1, x2, y2, x3, y3, xp, yp = map(float, l.split())
    s1 = get_triangle_area(x1, y1, x2, y2, x3, y3)
    s2 = get_triangle_area(xp, yp, x1, y1, x2, y2)
    s2 += get_triangle_area(xp, yp, x2, y2, x3, y3)
    s2 += get_triangle_area(xp, yp, x3, y3, x1, y1)
    print("YES" if round(s1, 10) == round(s2, 10) else "NO")

Submission status: Wrong Answer

Solution code:
import sys


def outer(vec_a, vec_b):
    return vec_a[0] * vec_b[1] - vec_a[1] * vec_b[0]

try:
    while True:
        x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split())
        vec_12 = [x2-x1, y2-y1]
        vec_23 = [x3-x2, y3-y2]
        vec_31 = [x1-x3, y1-y3]
        vec_1p = [xp-x1, yp-y1]
        vec_2p = [xp-x2, yp-y2]
        vec_3p = [xp-x3, yp-y3]
        if (outer(vec_12, vec_1p) > 0 and
                outer(vec_23, vec_2p) > 0 and
                outer(vec_31, vec_3p) > 0):
            print('YES')
        else:
            print('NO')

except:
    sys.exit()

Submission status: Wrong Answer

Solution code:
# ????§???¢???????????????????????????sgn?????????

from sys import stdin
for line in stdin:
    x1,y1,x2,y2,x3,y3,xp,yp = [float(i) for i in line.split()]
    ab_cross_ap = (x2-x1)*(y1-yp)-(y2-y1)*(x1-xp)
    bc_cross_bp = (x3-x2)*(y2-yp)-(y3-y2)*(x2-xp)
    ca_cross_cp = (x1-x3)*(y3-yp)-(y1-y3)*(x3-xp)
    if ab_cross_ap < 0 and bc_cross_bp < 0 and ca_cross_cp:
        print("YES")
    else:
        print("NO")

Submission status: Wrong Answer

Solution code:
from sys import stdin
for line in stdin:
    x1,y1,x2,y2,x3,y3,xp,yp = [float(i) for i in line.split()]
    ab_cross_ap = (x2-x1)*(y1-yp)-(y2-y1)*(x1-xp)
    bc_cross_bp = (x3-x2)*(y2-yp)-(y3-y2)*(x2-xp)
    ca_cross_cp = (x1-x3)*(y3-yp)-(y1-y3)*(x3-xp)
    if ab_cross_ap < 0 and bc_cross_bp < 0 and ca_cross_cp < 0:
        print("YES")
    else:
        print("NO")

Submission status: Wrong Answer

Solution code:

x1,y1,x2,y2,x3,y3,xp,yp=[float(p) for p in input().split()]

x_vector_1to2=x2-x1;
y_vector_1to2=y2-y1;
x_vector_1to3=x3-x1;
y_vector_1to3=y3-y1;
x_vector_p=xp-x1;
y_vector_p=yp-y1;

def renritu(p,q,r,s,t,u):  # renritu(p,q,r,s,t,u) px + qy = r  sx+ty=u
    a=p; b=q; c=r; d=s; e=t; f=u;
    a1=a*d; b1=b*d; c1=c*d; d1=d*a; e1=e*a; f1=f*a;
    res_y=b1-e1;
    if res_y != 0 :
        res_y =(c1-f1)/res_y;
        res_x =(c-b*res_y)/a;
        return(res_x,res_y)
    else:
        return(-1,-1)
    
res=renritu(x_vector_1to2,x_vector_1to3,x_vector_p,y_vector_1to2,y_vector_1to3,y_vector_p)
if res[0]>0 and res[1]>0 and res[0]+res[1]<1:
    print("YES")
else:
    print("NO")