숫자고르기1 숫자고르기 - Python https://www.acmicpc.net/problem/2668 코드 def solution(N, graph): visited = [False] * (N + 1) result = [] def dfs(start): stack, path = [start], [] while stack: node = stack.pop() if visited[node]: # 싸이클 발견 if node in path: idx = path.index(node) result.extend(path[idx:]) return .. 2025. 1. 22. 이전 1 다음