top of page

소스 코드 제출

공개·회원 71명

dasfasd


def dfs1(x, y) :
    global l, M, N, c2
    print(x,y,l[x][y])
    if l[x][y] == 0 :
        b=1
        l[x][y] = 9
        if y < N-1 :
            b+=dfs1(x, y+1)
        if x < M-1 :
            b+=dfs1(x+1, y)
        if y > 0 :
            b+=dfs1(x, y-1)
        if x > 0 :
            b+=dfs1(x-1, y)
        return b
    return 0

M, N, K = map(int, input().split())
l = [[0 for i in range(N)] for j in range(M)]
k = []
a = []
c1 = 0
c2 = 0
for _ in range(K):
    d = list(map(int, input().split()))
    for i in range(d[1], d[3]) :
        for j in range(d[0], d[2]) :
            l[i][j] = 1

for i in range(M) :
    for j in range(N):
        if l[i][j] == 0 :
            a.append(dfs1(i, j))
            c1 += 1

a.sort()
print(c1)
for i in range(len(a)) :
    print(a[i], end=' ')

1회 조회
주소 : 경기도 용인시 광교중앙로 302 블루 스퀘어 602호
연락처 : 031) 216 - 1546 ,     031) 215 - 1546
사업자등록번호 : 465-92-00916
​학원 등록 제 4603호
bottom of page