백준 10026 - 적록 색약


백준 10026 - 적록 색약

12345678910111213141516171819202122232425262728293031323334353637383940import sysfrom collections import deque def bfs(i,j,c): q = deque() q.append((i,j)) visit[i][j] = 1 while q: y,x = q.popleft() for dx,dy in (0,1),(0,-1),(-1,0),(1,0): nx,ny = x +dx, y + dy if 0 <= nx < n and 0 <= ny < n: if visit[ny][nx] == 0: if c == 1: if graph[y][x] == "G": graph[y][x] = "R" if graph[ny][nx] == "G": graph[ny][nx] = "R" if graph[ny][nx] == graph[y][x]: q.append((ny, nx)) visit[ny][nx] = 1 def call(c): cnt = 0 for i in range(n): for j in range(n): if visit[i][j] == 0: cnt += 1 bfs(i, j,c) print..........



원문링크 : 백준 10026 - 적록 색약