#!/usr/bin/env python3 """Algorithm: Subdivide the 30x30 grid into unit squares (from now on blocks). Put all blocks in a heap. Let A = 0 , the answer While the heap is non-empty, pop a block B off the heap. If B is 0: allzero = False if allzero: return 0 return 1 n = int(sys.stdin.readline()) circles = [] for _ in range(n): circles.append(C(*map(int, sys.stdin.readline().split()))) blocks = [] for i in range(-10, 20): for j in range(-10, 20): nw = P(i, j) ne = P(i + 1, j) sw = P(i, j + 1) se = P(i + 1, j + 1) blocks.append(B(nw, ne, sw, se)) heapq.heapify(blocks) area = 0 while blocks: block = heapq.heappop(blocks) containment = block_in_single_circle(block, circles) if containment == 4: area += block_area(block) elif containment == 0: continue else: for nb in subdivide(block): if block_area(nb) > TINY: heapq.heappush(blocks, nb) print(round(area, 4))