Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 학습
- 타코트론
- 보코더
- 윈도우
- 노래합성
- korean tts
- TTS
- DCTTS
- 트레이닝
- 한국어 음성 합성
- 딥러닝 음성 합성
- 음성 합성
- waveglow
- tacotron
- 한국어 tts
- melgan
- 딥러닝
- deep voice
- you only look once
- singing voice synthesis
- Vocoder
- YOLO
- 딥러닝 보코더
- text-to-speech
Archives
- Today
- Total
chldkato
백준 5427 불 (파이썬) 본문
https://www.acmicpc.net/problem/5427
5427번: 불
문제 상근이는 빈 공간과 벽으로 이루어진 건물에 갇혀있다. 건물의 일부에는 불이 났고, 상근이는 출구를 향해 뛰고 있다. 매 초마다, 불은 동서남북 방향으로 인접한 빈 공간으로 퍼져나간다. 벽에는 불이 붙지 않는다. 상근이는 동서남북 인접한 칸으로 이동할 수 있으며, 1초가 걸린다. 상근이는 벽을 통과할 수 없고, 불이 옮겨진 칸 또는 이제 불이 붙으려는 칸으로 이동할 수 없다. 상근이가 있는 칸에 불이 옮겨옴과 동시에 다른 칸으로 이동할 수 있다. 빌딩
www.acmicpc.net
1. 불이 날 예정인 지점은 이동하지 못하므로 불, 상근이 순으로 이동한다
2. 상근이가 (0,0) ~ (h-1,w-1) 범위를 벗어나면 탈출에 성공했으므로 걸린 시간을 출력
from collections import deque
import sys
input = sys.stdin.readline
dx = [1, -1, 0, 0]
dy = [0, 0, 1, -1]
def bfs(x, y):
q.append([x, y])
c[x][y] = 1
while q:
qlen = len(q)
while qlen:
x, y = q.popleft()
for i in range(4):
nx = x + dx[i]
ny = y + dy[i]
if 0 <= nx < h and 0 <= ny < w:
if a[nx][ny] == '.' and c[nx][ny] == 0:
c[nx][ny] = c[x][y] + 1
q.append([nx, ny])
elif nx < 0 or ny < 0 or nx >= h or ny >= w:
print(c[x][y])
return
qlen -= 1
fire()
print("IMPOSSIBLE")
return
def fire():
qlen = len(fq)
while qlen:
x, y = fq.popleft()
for i in range(4):
nx = x + dx[i]
ny = y + dy[i]
if 0 <= nx < h and 0 <= ny < w:
if a[nx][ny] == '.':
a[nx][ny] = '*'
fq.append([nx, ny])
qlen -= 1
tc = int(input())
while tc:
w, h = map(int, input().split())
a = [list(map(str, input().strip())) for _ in range(h)]
fq, q = deque(), deque()
c = [[0]*w for _ in range(h)]
for i in range(h):
for j in range(w):
if a[i][j] == '@':
sx = i; sy = j
a[i][j] = '.'
if a[i][j] == '*':
fq.append([i, j])
fire()
bfs(sx, sy)
tc -= 1
'백준' 카테고리의 다른 글
백준 2251 물통 (파이썬) (0) | 2020.02.18 |
---|---|
백준 9372 상근이의 여행 (파이썬) (0) | 2020.02.18 |
백준 1600 말이 되고픈 원숭이 (파이썬) (0) | 2020.02.17 |
백준 1325 효율적인 해킹 (파이썬) (0) | 2020.02.17 |
백준 1613 역사 (파이썬) (0) | 2020.02.17 |
Comments