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
pythondef main(): import sys input = sys.stdin.read().split() ptr = 0 N = int(input[ptr]) ptr += 1 diff = [[0] * 1001 for _ in range(1001)] for _ in range(N): x1 = int(input[ptr]) y1 = int(input[ptr+1]) x2 = int(input[ptr+2]) y2 = int(input[ptr+3]) ptr += 4 diff[x1][y1] += 1 diff[x1][y2] -= 1 diff[x2][y1] -= 1 diff[x2][y2] += 1 # Compute row-wise prefix sums for i in range(1001): current = 0 for j in range(1001): current += diff[i][j] diff[i][j] = current # Compute column-wise prefix sums for j in range(1001): current = 0 for i in range(1001): current += diff[i][j] diff[i][j] = current max_val = 0 for row in diff: current_max = max(row) if current_max > max_val: max_val = current_max print(max_val) if __name__ == "__main__": main()
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.