Official
C - スイッチと電球 / Switches and Light Bulbs Editorial
by
C - スイッチと電球 / Switches and Light Bulbs Editorial
by
sounansya
Editorial for printing
各クエリに対し、与えられたマスとその周辺 \(4\) マスを反転する操作を愚直に行えば良いです。
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
q = int(input())
for _ in range(q):
r, c = map(int, input().split())
r -= 1
c -= 1
for dr, dc in ((0, 0), (0, 1), (0, -1), (1, 0), (-1, 0)):
x, y = r + dr, c + dc
if 0 <= x < h and 0 <= y < w:
s[x][y] = '1' if s[x][y] == '0' else '0'
for row in s:
print(''.join(row))
posted:
last update:
