import sys
sys.setrecursionlimit(10**7)
def dfs1(x, y) :
global l, M, N, c2
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=' ')
'''
'''
queue = [1]
b = [1]
c = 0
N = int(input())
t = int(input())
l = [[] for i in range(t+1)]
for i in range(t) :
n, m = map(int, input().split())
l[n-1].append(m)
l[m-1].append(n)
print(l)
while len(queue) != 0 :
a = queue.pop(0)
for i in l[a-1] :
if i not in b :
queue.append(i)
b.append(i)
c += 1
print(c)
'''
'''
def Bfs(l, x, y) :
c2=1
queue = [[x, y]]
l[x][y] = 9
while len(queue) != 0:
q = queue.pop(0)
if q[0]+1 < N and l[q[0]+1][q[1]]=='1':
queue.append([q[0]+1, q[1]])
l[q[0]+1][q[1]] = 9
c2 += 1
if q[0]-1 >= 0 and l[q[0]-1][q[1]]=='1':
queue.append([q[0]-1, q[1]])
l[q[0]-1][q[1]] = 9
c2 += 1
if q[1]+1 < N and l[q[0]][q[1]+1]=='1':
queue.append([q[0], q[1]+1])
l[q[0]][q[1]+1] = 9
c2 += 1
if q[1]-1 >= 0 and l[q[0]][q[1]-1]=='1':
queue.append([q[0], q[1]-1])
l[q[0]][q[1]-1] = 9
c2 += 1
return c2
N = int(input())
l = []
t = []
c1 = 0
for i in range(N) :
h = input()
l.append(list(h))
for i in range(N) :
for j in range(N) :
if l[i][j] == '1' :
t.append(Bfs(l, i, j))
c1 += 1
print(c1)
t.sort()
for i in t:
print(i)
'''
def Bfs(l, x, y)
c = 0
l = []
for i in range(7) :
m = list(map(int, input().split()))
l.append(m)
for i in range(7) :
for j in range(7) :
Bfs(l, i, j)
c += 1top of page

실제 작동 상태를 확인하려면 라이브 사이트로 이동하세요.
250601
250601
댓글 0개
좋아요
댓글(0)
더 이상 게시물에 대한 댓글 기능이 지원되지 않습니다. 자세한 사항은 사이트 소유자에게 문의하세요.
bottom of page


