Skip to content

Commit 20751e7

Browse files
committed
[Add] Baekjoon > Q16918.py
1 parent b7f91f7 commit 20751e7

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

Baekjoon/Q16918.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# link: https://www.acmicpc.net/problem/16918
2+
# 다시 풀어봐야 됨
3+
4+
import sys
5+
input = sys.stdin.readline
6+
7+
r, c, n = map(int, input().split())
8+
board = [list(input().strip()) for i in range(r)]
9+
10+
if n<=1 :
11+
for li in board : print(''.join(li))
12+
elif n%2==0 :
13+
for i in range(r): print('O'*c)
14+
else :
15+
# 첫번째 폭탄이 터진 상태
16+
bombs1 = [['O']*c for i in range(r)]
17+
for y in range(r):
18+
for x in range(c):
19+
if board[y][x]=='O': bombs1[y][x] = '.'
20+
else :
21+
for i, j in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
22+
if y+i>=0 and y+i<r and x+j>=0 and x+j<c and board[y+i][x+j]=='O':
23+
bombs1[y][x] = '.'
24+
break
25+
26+
# 두번째 폭탄이 터진 상태
27+
bombs2 = [['O']*c for i in range(r)]
28+
for y in range(r):
29+
for x in range(c):
30+
if bombs1[y][x]=='O' : bombs2[y][x] = '.'
31+
else :
32+
for i, j in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
33+
if y+i>=0 and y+i<r and x+j>=0 and x+j<c and bombs1[y+i][x+j]=='O':
34+
bombs2[y][x] = '.'
35+
break
36+
37+
if n%4==3:
38+
for li in bombs1 : print(''.join(li))
39+
if n%4==1:
40+
for li in bombs2 : print(''.join(li))

0 commit comments

Comments
 (0)