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
- 한국어 tts
- waveglow
- melgan
- YOLO
- 보코더
- you only look once
- 학습
- 딥러닝
- 한국어 음성 합성
- 타코트론
- 음성 합성
- 트레이닝
- 윈도우
- 노래합성
- DCTTS
- deep voice
- 딥러닝 보코더
- tacotron
- 딥러닝 음성 합성
- text-to-speech
- TTS
- singing voice synthesis
- Vocoder
- korean tts
Archives
- Today
- Total
chldkato
백준 1261 알고스팟 (파이썬) 본문
https://www.acmicpc.net/problem/1261
1261번: 알고스팟
첫째 줄에 미로의 크기를 나타내는 가로 크기 M, 세로 크기 N (1 ≤ N, M ≤ 100)이 주어진다. 다음 N개의 줄에는 미로의 상태를 나타내는 숫자 0과 1이 주어진다. 0은 빈 방을 의미하고, 1은 벽을 의미한다. (1, 1)과 (N, M)은 항상 뚫려있다.
www.acmicpc.net
벽을 부수는 횟수를 가중치로 생각하여 다익스트라를 수행한다
목표값에 도달하였을 때의 부순 횟수를 출력하면 부순 벽의 최소값이 된다
from heapq import heappush, heappop
import sys
input = sys.stdin.readline
INF = sys.maxsize
dx = [1, -1, 0, 0]
dy = [0, 0, 1, -1]
def dij():
heappush(q, [0, 0, 0])
d[0][0] = 1
while q:
w, x, y = heappop(q)
if x == m-1 and y == n-1:
print(w)
return
for i in range(4):
nx = x + dx[i]
ny = y + dy[i]
if 0 <= nx < m and 0 <= ny < n:
nw = w + a[nx][ny]
if nw < d[nx][ny]:
d[nx][ny] = nw
heappush(q, [nw, nx, ny])
n, m = map(int, input().split())
a = [list(map(int, input().strip())) for _ in range(m)]
d = [[INF]*n for _ in range(m)]
q = []
dij()
'백준' 카테고리의 다른 글
백준 1504 특정한 최단 경로 (파이썬) (0) | 2020.02.17 |
---|---|
백준 1238 파티 (파이썬) (0) | 2020.02.17 |
백준 11559 Puyo Puyo (파이썬) (0) | 2020.02.17 |
백준 1967 트리의 지름 (파이썬) (1) | 2020.02.17 |
백준 1963 소수 경로 (파이썬) (0) | 2020.02.17 |
Comments