BOJ - 12781 - PIZZA ALVOLOC

Updated:

import sys

def isCCW(p1, p2, p3):
    ret = (p2[0] - p1[0]) * (p3[1] - p1[1]) - (p2[1] - p1[1]) * (p3[0] - p1[0])
    if (ret < 0): return 1
    elif (ret > 0): return -1
    else: return 0
    
def solution():
    x1, y1, x2, y2, x3, y3, x4, y4 = map(int, sys.stdin.readline().split())

    r1 = isCCW([x1, y1], [x2, y2], [x3, y3])
    r2 = isCCW([x1, y1], [x2, y2], [x4, y4])
    ret = r1 * r2
    if ret < 0: print(1)
    else: print(0)

solution()

https://www.acmicpc.net/problem/12781

Categories:

Updated:

Leave a comment