문제링크 : https://school.programmers.co.kr/learn/courses/30/lessons/92343
def solution(info, edges):
ans = []
visited = [0] * len(info)
def dfs(sheep, wolf):
if wolf >= sheep:
return
else:
ans.append(sheep)
for p,c in edges:
if visited[p] and not visited[c]:
visited[c] = 1
if info[c] == 0:
dfs(sheep+1,wolf)
else:
dfs(sheep, wolf+1)
visited[c] = 0
visited[0] = 1
dfs(1,0)
return max(ans)