백준 11758 - CCW (파이썬)

Updated:

CCW라는 공식을 사용하면 풀 수 있습니다.

import sys
input = sys.stdin.readline

dot = [list(map(int, input().split())) for _ in range(3)]

def ccw(p1, p2, p3):
    x1, y1 = p1
    x2, y2 = p2
    x3, y3 = p3
    
    return (x1 * y2 + x2 * y3 + x3 * y1) - (x2 * y1 + x3 * y2 + x1 * y3) 

result = ccw(dot[0], dot[1], dot[2]) 

if result > 0:
    print(1)
elif result < 0:
    print(-1)
else:
    print(0)

Categories:

Updated: