CT15 [Python] 백준 1303번 : 전쟁 - 전투 https://www.acmicpc.net/problem/1303 🚩DFS 코드import sysinput = sys.stdin.readlinesys.setrecursionlimit(100000)def dfs(y, x, color) : global cnt if x = N or y = M: return 0 if check[y][x] == False and graph[y][x] == color: check[y][x] = True cnt += 1 for i in range(4): dfs(y + dy[i], x + dx[i], color) retur.. 2024. 10. 30. [Python] 백준 1012번 : 유기농 배추 https://www.acmicpc.net/problem/1012 🚩DFS 코드import sysinput = sys.stdin.readlinesys.setrecursionlimit(10000)def dfs(x, y) : if x = M or y >= N : return False if graph[y][x] == 1 : graph[y][x] = 0 for i in range(4): dfs(x + dx[i], y + dy[i]) return True return FalseT = int(input())dx = [-1, 1, 0, 0]dy = [0, 0, -1, 1]for _ in r.. 2024. 10. 12. [알고리즘 고득점 Kit] Heap : 더 맵게 https://school.programmers.co.kr/learn/courses/30/lessons/42626?language=python3 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 2024. 10. 5. [Python] 백준 2667번 : 단지번호붙이기 https://www.acmicpc.net/problem/2667 대각선상에 집이 있는 경우는 연결된 것이 아니다 == 상하좌우 확인 DFSimport sysN = int(sys.stdin.readline().rstrip())graph = [ list(map(int,sys.stdin.readline().rstrip())) for _ in range(N)]result = []cnt = 0def dfs(x, y): global cnt if x = N or y = N: return False if graph[x][y] == 1: cnt += 1 graph[x][y] = 0 dfs(x-1,y) dfs(x+1,y) .. 2024. 9. 9. 이전 1 2 3 4 다음