Given a set of $N$ axis-aligned rectangular seals, find the number of overlapped seals…
- User
Given a set of axis-aligned rectangular seals, find the number of overlapped seals on the region which has the maximum number of overlapped seals.
Constraints
Assistant
n = int(input()) diff = [[0] * 1001 for _ in range(1001)] for _ in range(n): x1, y1, x2, y2 = map(int, input().split()) diff[x1][y1] += 1 diff[x1][y2] -= 1 diff[x2][y1] -= 1 diff[x2][y2] += 1 # Compute row-wise prefix sums for x in range(1001): current = 0 for y in range(1001): current += diff[x][y] diff[x][y] = current # Compute column-wise prefix sums for y in range(1001): current = 0 for x in range(1001): current += diff[x][y] diff[x][y] = current # Find maximum value max_overlap = 0 for x in range(1001): for y in range(1001): if diff[x][y] > max_overlap: max_overlap = diff[x][y] print(max_overlap)
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.