【マップの扱い 1】マップの書き換え・1 マス Python3編
https://paiza.jp/works/mondai/b_rank_new_level_up_problems/python3/b_rank_new_level_up_problems__get_one/result?token=9ed0c6d47f5e871285f9e41d4599f1db
code:py
H, W = map(int, input().split())
lines = []
for _ in range(H):
line = char for char in input()
lines.append(line)
x, y = map(int, input().split())
if linesxy == '.':
linesxy = '#'
else:
linesxy = '.'
for i in lines:
print(''.join(i))
code:py
H, W = map(int, input().split())
lines = []
for _ in range(H):
line = char for char in input()
lines.append(line)
y, x = map(int, input().split())
# 上の行
if y - 1 >= 0:
target_upper_line = linesy - 1
if target_upper_linex == '#':
target_upper_linex = '.'
else:
target_upper_linex = '#'
# 中央の行の左・中央・右
target_line = linesy
if x - 1 >= 0: # 左側のマス
if target_linex - 1 == '#':
target_linex - 1 = '.'
else:
target_linex - 1 = '#'
if target_linex == '#': # 中央のマス
target_linex = '.'
else:
target_linex = '#'
if x + 1 < W: # 右側のマス
if target_linex + 1 == '#':
target_linex + 1 = '.'
else:
target_linex + 1 = '#'
# 下の行
if y + 1 < H:
target_under_line = linesy + 1
if target_under_linex == '#':
target_under_linex = '.'
else:
target_under_linex = '#'
# 結果出力
for line in lines:
print(''.join(line))