전쟁-전투[백준 1303]
https://www.acmicpc.net/problem/1303 from collections import deque n, m = map(int, input().split())arr = [list(input().strip()) for _ in range(m)]visit = [[0] * n for _ in range(m)]b, w = [], []dx, dy = [1, -1, 0, 0], [0, 0, 1, -1]def bfs(x, y, char): q = deque() q.append((x, y)) cnt = 1 visit[x][y] = 1 while q: x, y = q.popleft() for i in range(4): nx,..
양치기 꿍[백준 3187]
https://www.acmicpc.net/problem/3187from collections import dequeimport sysinput = sys.stdin.readdata = input().split("\n")R, C = map(int, data[0].split())graph = [list(data[i]) for i in range(1, R+1)]dx = [-1, 1, 0, 0]dy = [0, 0, -1, 1]visited = [[False] * C for _ in range(R)]def bfs(x, y): queue = deque([(x, y)]) visited[x][y] = True sheep, wolf = 0, 0 # 현재 영역의 양과 늑대 수 while queue..