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
- singing voice synthesis
- 타코트론
- 트레이닝
- 학습
- 딥러닝 보코더
- 노래합성
- 딥러닝 음성 합성
- 음성 합성
- deep voice
- 보코더
- tacotron
- 한국어 tts
- 한국어 음성 합성
- text-to-speech
- melgan
- waveglow
- you only look once
- Vocoder
- YOLO
- 윈도우
- 딥러닝
- DCTTS
- korean tts
- TTS
Archives
- Today
- Total
chldkato
백준 2667 단지번호붙이기 (파이썬) 본문
https://www.acmicpc.net/problem/2667
2667번: 단지번호붙이기
<그림 1>과 같이 정사각형 모양의 지도가 있다. 1은 집이 있는 곳을, 0은 집이 없는 곳을 나타낸다. 철수는 이 지도를 가지고 연결된 집들의 모임인 단지를 정의하고, 단지에 번호를 붙이려 한다. 여기서 연결되었다는 것은 어떤 집이 좌우, 혹은 아래위로 다른 집이 있는 경우를 말한다. 대각선상에 집이 있는 경우는 연결된 것이 아니다. <그림 2>는 <그림 1>을 단지별로 번호를 붙인 것이다. 지도를 입력하여 단지수를 출력하고, 각 단지에 속하는 집의 수
www.acmicpc.net
dx = [1, -1, 0, 0]
dy = [0, 0, 1, -1]
def bfs(x, y, cnt):
q = [[x, y]]
check[x][y] = cnt
while q:
x = q[0][0]
y = q[0][1]
q.pop(0)
for i in range(4):
nx = x + dx[i]
ny = y + dy[i]
if 0 <= nx < n and 0 <= ny < n:
if a[nx][ny] == 1 and check[nx][ny] == 0:
check[nx][ny] = cnt
q.append([nx, ny])
n = int(input())
a = [list(map(int, input())) for _ in range(n)]
check = [[0]*n for _ in range(n)]
cnt = 1
for i in range(n):
for j in range(n):
if a[i][j] == 1 and check[i][j] == 0:
bfs(i, j, cnt)
cnt += 1
count = [0 for _ in range(cnt)]
for i in range(n):
for j in range(n):
if check[i][j] != 0:
count[check[i][j]] += 1
count = count[1:]
count.sort()
cnt -= 1
print(cnt)
for i in range(cnt):
print(count[i])
'백준' 카테고리의 다른 글
백준 1697 숨바꼭질 (파이썬) (0) | 2020.02.27 |
---|---|
백준 7576 토마토 (파이썬) (0) | 2020.02.27 |
백준 2178 미로 탐색 (파이썬) (0) | 2020.02.27 |
백준 2931 가스관 (파이썬) (2) | 2020.02.26 |
백준 2151 거울 설치 (파이썬) (0) | 2020.02.25 |
Comments