Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n = int(input())
- count = 0
- def line(x,y,x1,y1,x2,y2,x3,y3):
- if x1 == x2:
- if x1 >= x3 and x1 >= x: return True
- elif x1 <= x3 and x1 <= x: return True
- else: return False
- elif y1 == y2:
- if y1 >= y3 and y1 >= y: return True
- elif y1 <= y3 and y1 <= y: return True
- else: return False
- else:
- x0 = x1-x2
- y0 = y1-y2
- k = y0/x0
- b = y1-x1*k
- if y3 >= k*x3+b and y >= k*x+b: return True
- elif y3 <= k*x3+b and y <= k*x+b: return True
- else: return False
- for i in range(n):
- (x,y,x1,y1,x2,y2,x3,y3,x4,y4) = map(int,input().split())
- if line(x,y,x1,y1,x2,y2,x3,y3) and line(x,y,x2,y2,x3,y3,x4,y4) and line(x,y,x3,y3,x4,y4,x1,y1) and line(x,y,x4,y4,x1,y1,x2,y2):
- count+=1
- print(count)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement