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 |
Tags
- 윈도우
- 한국어 tts
- 딥러닝 보코더
- deep voice
- DCTTS
- melgan
- 음성 합성
- 타코트론
- you only look once
- 트레이닝
- 딥러닝 음성 합성
- YOLO
- singing voice synthesis
- tacotron
- korean tts
- 보코더
- 노래합성
- waveglow
- TTS
- 한국어 음성 합성
- Vocoder
- 딥러닝
- text-to-speech
- 학습
Archives
- Today
- Total
chldkato
백준 2234 성곽 (파이썬) 본문
https://www.acmicpc.net/problem/2234
2234번: 성곽
문제 대략 위의 그림과 같이 생긴 성곽이 있다. 굵은 선은 벽을 나타내고, 점선은 벽이 없어서 지나다닐 수 있는 통로를 나타낸다. 이러한 형태의 성의 지도를 입력받아서 다음을 계산하는 프로그램을 작성하시오. 이 성에 있는 방의 개수 가장 넓은 방의 넓이 하나의 벽을 제거하여 얻을 수 있는 가장 넓은 방의 크기 위의 예에서는 방은 5개고, 가장 큰 방은 9개의 칸으로 이루어져 있으며, 위의 그림에서 화살표가 가리키는 벽을 제거하면 16인 크기의 방을 얻을
www.acmicpc.net
1. 동서남북에 맞춰 방향과 마주칠 벽의 번호 설정. (동쪽으로 이동할 경우 다음칸의 서쪽벽과 마주침)
2. 비트연산으로 현재 이동방향과 다음칸에 벽이 있는지 확인하면서 이동
3. 필요한 답을 반복문으로 출력
from collections import deque
import sys
input = sys.stdin.readline
dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]
dir = [1, 2, 4, 8]
def bfs(x, y, cnt):
q.append([x, y])
c[x][y] = cnt
while q:
x, y = q.popleft()
for i in range(4):
nx = x + dx[i]
ny = y + dy[i]
if 0 <= nx < m and 0 <= ny < n:
if dir[i] & ~a[nx][ny] and c[nx][ny] == 0:
c[nx][ny] = cnt
q.append([nx, ny])
n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(m)]
c = [[0]*n for _ in range(m)]
q = deque()
cnt = 1
for i in range(m):
for j in range(n):
if c[i][j] == 0:
bfs(i, j, cnt)
cnt += 1
print(cnt-1)
ans = [0]*(cnt-1)
for i in range(m):
for j in range(n):
ans[c[i][j]-1] += 1
print(max(ans))
max_room = 0
for i in range(m):
for j in range(n):
for k in range(4):
ni = i + dx[k]
nj = j + dy[k]
if 0 <= ni < m and 0 <= nj < n:
if c[i][j] != c[ni][nj]:
room = ans[c[i][j]-1] + ans[c[ni][nj]-1]
max_room = max(room, max_room)
print(max_room)

'백준' 카테고리의 다른 글
백준 16236 아기 상어 (파이썬) (0) | 2020.02.21 |
---|---|
백준 1938 통나무 옮기기 (파이썬) (0) | 2020.02.20 |
백준 1194 달이 차오른다, 가자. (파이썬) (0) | 2020.02.20 |
백준 1939 중량제한 (파이썬) (0) | 2020.02.18 |
백준 1152 단어의 개수 (파이썬) (0) | 2020.02.18 |