대학 과제 - 선착장(계산기하학)

둘러봐 기술블로그·2023년 9월 11일
0
post-thumbnail

문제

입출력 예시

풀이

  • 예각, 둔각은 용어를 혼동함. 실제로는 180도 이상이냐 이하냐를 말하고자 함.

의사코드

코드

import numpy as np
import sys

count = int(sys.stdin.readline())
P = [list(map(int, sys.stdin.readline().split())) for _ in range(count)]

def marina():
  global P

  no_answer = True

  length = len(P)
  for i in range(length):

    AB = [P[i][0] - P[(i-1)%length][0], P[i][1] - P[(i-1)%length][1]]
    BC = [P[(i+1)%length][0] - P[i][0], P[(i+1)%length][1] - P[i][1]]
    T = np.array(AB + BC).reshape(2, 2, order='F')
    signed_area = np.linalg.det(T)

    if signed_area < 0: 
      print(i+1)
      no_answer = False
  

  if no_answer: print(0)

marina()
profile
move out to : https://lobster-tech.com?utm_source=velog

0개의 댓글