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 |
Tags
- 노래합성
- melgan
- korean tts
- tacotron
- 보코더
- 딥러닝 음성 합성
- 한국어 음성 합성
- deep voice
- 한국어 tts
- TTS
- YOLO
- Vocoder
- 트레이닝
- singing voice synthesis
- 음성 합성
- text-to-speech
- you only look once
- 딥러닝
- 윈도우
- 학습
- 타코트론
- 딥러닝 보코더
- waveglow
- DCTTS
Archives
- Today
- Total
chldkato
백준 2583 영역 구하기 (파이썬) 본문
https://www.acmicpc.net/problem/2583
2583번: 영역 구하기
첫째 줄에 M과 N, 그리고 K가 빈칸을 사이에 두고 차례로 주어진다. M, N, K는 모두 100 이하의 자연수이다. 둘째 줄부터 K개의 줄에는 한 줄에 하나씩 직사각형의 왼쪽 아래 꼭짓점의 x, y좌표값과 오른쪽 위 꼭짓점의 x, y좌표값이 빈칸을 사이에 두고 차례로 주어진다. 모눈종이의 왼쪽 아래 꼭짓점의 좌표는 (0,0)이고, 오른쪽 위 꼭짓점의 좌표는(N,M)이다. 입력되는 K개의 직사각형들이 모눈종이 전체를 채우는 경우는 없다.
www.acmicpc.net
입력 받은 좌표값에 맞춰 반복문을 돌려 직사각형 범위를 1로 설정하고
bfs로 0에 해당하는 영역에 번호를 붙이면 되는 문제
from collections import deque
dx = [1, -1, 0, 0]
dy = [0, 0, 1, -1]
def bfs(x, y, cnt):
q.append([x, y])
a[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 < n and 0 <= ny < m:
if a[nx][ny] == 0:
a[nx][ny] = cnt
q.append([nx, ny])
m, n, k = map(int, input().split())
a = [[0]*m for _ in range(n)]
c = a[:]
q = deque()
for _ in range(k):
x1, y1, x2, y2 = map(int, input().split())
for i in range(x1, x2):
for j in range(y1, y2):
a[i][j] = -1
cnt = 1
for i in range(n):
for j in range(m):
if a[i][j] == 0:
bfs(i, j, cnt)
cnt += 1
cnt -= 1
print(cnt, end='\n')
ans = [0] * cnt
for i in range(n):
for j in range(m):
if a[i][j] > 0:
ans[a[i][j]-1] += 1
ans.sort()
for i in range(len(ans)):
print("{0} ".format(ans[i]), end='')
'백준' 카테고리의 다른 글
백준 1697 숨바꼭질 (파이썬) (0) | 2020.02.16 |
---|---|
백준 2468 안전 영역 (파이썬) (0) | 2020.02.16 |
백준 6603 로또 (파이썬) (3) | 2020.02.16 |
백준 7562 나이트의 이동 (파이썬) (0) | 2020.02.16 |
백준 7569 토마토 (파이썬) (0) | 2020.02.16 |
Comments