Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n = int(input())
- xp = []
- yp = []
- for i in range(n):
- s = [int(x) for x in input().split()]
- xp.append(s[0])
- yp.append(s[1])
- x, y =[float(s) for s in input().split()]
- def inPolygon(x, y, xp, yp):
- c = 0
- for i in range(n):
- if (((yp[i] <= y and y < yp[i - 1]) or (yp[i - 1] <= y and y < yp[i])) and (x > (xp[i - 1] - xp[i]) * (y - yp[i]) / (yp[i - 1] - yp[i]) + xp[i])):
- c = 1 - c
- return c
- a =inPolygon(x,y,xp,yp)
- if a == 1:
- print('YES')
- else:
- print('NO')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement