-
카테고리
-
세부 분야
알고리즘 · 자료구조
-
해결 여부
미해결
1068번: 트리
23.02.26 11:16 작성 조회수 254
1
제가 다음과 같이 코드를 작성했는데,
100%까지 가다가 틀립니다..
어떤게 문제일까요? 반례를 제시해주실 수 있나요?
감사합니다.
https://www.acmicpc.net/problem/1068
import sys
input = sys.stdin.readline
n = int(input())
g = list(map(int, input().split()))
m = int(input())
cnt = 0
def DFS(x):
g[x] = -1
for i in range(n):
if g[i] == x:
DFS(i)
DFS(m)
for i in range(n):
if g[i] != -1 and i not in g:
cnt += 1
print(cnt)
답변을 작성해보세요.
-2
답변 1