Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Verify a rectangle covering.
- def main():
- domain, rects = input()
- domain = set(domain)
- for (x, y, w, h) in rects:
- if w <= 0 or h <= 0:
- return "Degenerate rectangle at %s."%((x,y),)
- for i in range(x, x+w):
- for j in range(y, y+h):
- if (i,j) in domain:
- domain.remove((i,j))
- else:
- return "Coordinate %s covered incorrectly."%((i,j),)
- for (x2, y2, w2, h2) in rects:
- if x == x2 and w == w2 and y + h == y2:
- return "Aligned rectangles at %s and %s."%((x,y),(x2,y2))
- if y == y2 and h == h2 and x + w == x2:
- return "Aligned rectangles at %s and %s."%((x,y),(x2,y2))
- if domain:
- return "Coordinate %s not covered."%(domain.pop(),)
- else:
- return "The covering is valid."
- if __name__ == "__main__":
- print main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement