Created
December 27, 2025 00:39
-
-
Save maehrm/08e1d4fa471d7de5e757e9b70bb092bc to your computer and use it in GitHub Desktop.
D - Garbage Removal https://atcoder.jp/contests/abc406/tasks/abc406_d
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| H, W, N = map(int, input().split()) | |
| row = [set() for _ in range(H + 1)] | |
| col = [set() for _ in range(W + 1)] | |
| for _ in range(N): | |
| x, y = map(int, input().split()) | |
| row[x].add(y) # x行目のy列目にゴミがある | |
| col[y].add(x) # y列目のx行目にゴミがある。 | |
| Q = int(input()) | |
| for _ in range(Q): | |
| t, n = map(int, input().split()) | |
| if t == 1: | |
| print(len(row[n])) | |
| for i in row[n]: | |
| col[i].remove(n) | |
| row[n].clear() | |
| else: | |
| print(len(col[n])) | |
| for i in col[n]: | |
| row[i].remove(n) | |
| col[n].clear() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment