
문제 https://www.acmicpc.net/problem/10026 10026번: 적록색약 적록색약은 빨간색과 초록색의 차이를 거의 느끼지 못한다. 따라서, 적록색약인 사람이 보는 그림은 아닌 사람이 보는 그림과는 좀 다를 수 있다. 크기가 N×N인 그리드의 각 칸에 R(빨강), G(초록) www.acmicpc.net 코드 import collections n = int(input()) graph = [list(input()) for _ in range(n)] check = [[False]*n for _ in range(n)] queue = collections.deque() dx, dy = [-1, 1, 0, 0], [0, 0, -1, 1] count1=0 count2=0 def bfs(x,y):..

문제 https://www.acmicpc.net/problem/2583 2583번: 영역 구하기 첫째 줄에 M과 N, 그리고 K가 빈칸을 사이에 두고 차례로 주어진다. M, N, K는 모두 100 이하의 자연수이다. 둘째 줄부터 K개의 줄에는 한 줄에 하나씩 직사각형의 왼쪽 아래 꼭짓점의 x, y좌표값과 오 www.acmicpc.net 코드 import collections m, n, k = map(int, input().split()) # m 세로, n 가로 graph = [[0]*n for _ in range(m)] check = [[False]*n for _ in range(m)] dx, dy = [-1, 1, 0, 0], [0, 0, -1, 1] count = 0 result = [] def bf..

문제 https://www.acmicpc.net/problem/4963 4963번: 섬의 개수 입력은 여러 개의 테스트 케이스로 이루어져 있다. 각 테스트 케이스의 첫째 줄에는 지도의 너비 w와 높이 h가 주어진다. w와 h는 50보다 작거나 같은 양의 정수이다. 둘째 줄부터 h개 줄에는 지도 www.acmicpc.net 코드 import collections while True: w, h = map(int, input().split()) if w == 0 and h == 0: break graph = [list(map(int,input().split())) for _ in range(h)] check = [[False]*w for _ in range(h)] def bfs(x,y): queue = col..

문제 https://programmers.co.kr/learn/courses/30/lessons/43162?language=python3 코딩테스트 연습 - 네트워크 네트워크란 컴퓨터 상호 간에 정보를 교환할 수 있도록 연결된 형태를 의미합니다. 예를 들어, 컴퓨터 A와 컴퓨터 B가 직접적으로 연결되어있고, 컴퓨터 B와 컴퓨터 C가 직접적으로 연결되어 있 programmers.co.kr 코드 import collections def solution(n, computers): def bfs(index): count = -1 check[index] = True queue = collections.deque() queue.append(index) while queue: count += 1 cur = queue..