D3_10761_신뢰 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 from collections import deque for T in range(int(input())): command = deque(input().split()) N = command.popleft() B = deque() O = deque() order = deque() while command: i = command.
2178_미로탐색 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 32 33 34 35 import sys from collections import deque def isSafe(x, y): if 0 <= x < N and 0 <= y < M: return True def BFS(): while q: x, y = q.popleft() visited[x][y] = 1 for i in range(4): cx = x + dx[i] cy = y + dy[i] if isSafe(cx, cy) and arr[cx][cy] == 1 and visited[cx][cy] == 0: q.
1260_DFS와 BFS 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 32 33 34 35 36 37 38 39 40 41 42 import sys from collections import deque def DFS(V): print(V, end=' ') DFSv[V] = 1 for i in range(1, N+1): if DFSv[i] == 0 and tree[V][i] == 1: DFS(i) return def BFS(V): q = deque([V]) BFSv[V] = 1 while q: p = q.
10989_수 정렬하기3 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 import sys # 시간 초과 # from collections import deque # # result = deque() # for T in range(int(sys.stdin.readline().rstrip())): # n = int(sys.stdin.readline().rstrip()) # if len(result) != 0: # for i in range(len(result)): # if result[i] > n: # result.