Skip to content

Instantly share code, notes, and snippets.

@maehrm
Created December 27, 2025 00:39
Show Gist options
  • Select an option

  • Save maehrm/08e1d4fa471d7de5e757e9b70bb092bc to your computer and use it in GitHub Desktop.

Select an option

Save maehrm/08e1d4fa471d7de5e757e9b70bb092bc to your computer and use it in GitHub Desktop.
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