123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- import numpy as np
- class Plate:
- def __init__(self, h, s, z):
- self.height = []
- self.space = s
- self.zombies = z
- def addToPlates(plates, R, i, x, y):
- print(plates)
- newSpace = [x-R/2, x+R/2, y+R/2, y-R/2]
- newPlate = Plate(1, newSpace, [i])
- toAdd = []
- for p in plates:
- if newSpace[0] <= p.space[1] and newSpace[1] >= p.space[0] and newSpace[2] > p.space[3] and newSpace[3] < p.space[2]:
- # Overlap
- overlapSpace = [max(newSpace[0], p.space[0]), min(newSpace[1], p.space[1]), min(newSpace[2], p.space[2]), max(newSpace[3], p.space[3])]
- print(p.zombies)
- overlapPlate = Plate(newPlate.height + p.height, overlapSpace, p.zombies.extend(newPlate.zombies))
- toAdd.append(overlapPlate)
- plates.append(newPlate)
- plates.extend(toAdd)
- def solve(N, R, XY):
- # print("N={0}, R={1}, XY={2}".format(N, R, XY))
- # Create plates
- plates = []
- for i, xy in enumerate(XY):
- x, y = xy
- addToPlates(plates, R, i, x, y)
- print(plates)
- return 'white'
- if __name__ == "__main__":
- import fileinput
- f = fileinput.input()
- T = int(f.readline())
- for case in range(1, T+1):
- N, R = [int(i) for i in f.readline().split()]
- XY = [[int(i) for i in f.readline().split()] for x in range(N)]
- solution = solve(N, R, XY)
- print("Case #{0}: {1}".format(case, solution))
|