일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 만화도
- 링피트
- FIT XR
- leetcode
- 미드시청
- English
- 영어공부
- 영어원서읽기
- 잡생각
- 읽기
- 10분
- Problem Solving
- 스탭퍼
- Writing
- 매일
- 3줄정리
- 프로젝트
- 월간
- 화상영어
- realclass
- Daily Challenge
- 30분
- 파비최
- 괜찮음
- 사이드
- 리얼 클래스
- 운동
- 뭐든
- 쓰릴오브파이트
- 개발자
Archives
- Today
- Total
파비의 매일매일 공부기록
[BOJ] 1996 본문
https://www.acmicpc.net/problem/1996
주어진 조건대로 구현하면 됨.
딱히 어려운 건 없었으나, 문자(*, M) 출력이 조금 번거로웠음.
import sys
input = sys.stdin.readline
pos_x = [0, 1, 1, 1, 0, -1, -1, -1]
pos_y = [-1, -1, 0, 1, 1, 1, 0, -1]
n = int(input())
board = []
for _ in range(n):
board.append(list(input()))
res = [[0 for _ in range(n)] for __ in range(n)]
def fill_mines(board, x, y):
if board[y][x] == '.':
return
v = int(board[y][x])
for i in range(8):
if x + pos_x[i] < 0 or y + pos_y[i] < 0 or x + pos_x[i] >= n or y + pos_y[i] >= n:
continue
res[y + pos_y[i]][x + pos_x[i]] += v
for y in range(n):
for x in range(n):
fill_mines(board, x, y)
for y in range(n):
for x in range(n):
if board[y][x] != '.':
res[y][x] = '*'
else:
if int(res[y][x]) > 9:
res[y][x] = 'M'
print(res[y][x], end='')
print('')
반응형
'Problem Solving > BOJ' 카테고리의 다른 글
[BOJ] 2028 (0) | 2022.04.10 |
---|---|
[BOJ] 2010 (0) | 2022.04.09 |
[BOJ] 1977 (0) | 2022.04.07 |
[BOJ] 1975 (0) | 2022.04.06 |
[BOJ] 1964 [재시도 필요] (0) | 2022.04.05 |
Comments