I badly need some help. I am continuously getting Runtime Error(NZEC). I have checked with multiple test cases in my terminal and all have given right answers.
I can't find any reason why I am getting runtime error. Here is my code:
bombs, relations = map(int, input().split())
graph = [[] for i in range(bombs+1)]
for i in range(relations):
bomb1, bomb2 = map(int, input().split())
graph[bomb1].append(bomb2)
def dfs(bomb):
count = 1
visit[bomb] = 1
if len(graph[bomb]) > 0:
for i in graph[bomb]:
if visit[i] == 0:
count = count + dfs(i)
return count
maxImpact = 0
for i in range(1, bombs+1):
visit = [0 for i in range(bombs+1)]
impact = dfs(i)
if impact > maxImpact:
maxImpact = impact
print(maxImpact)
Please help me. Thanks in advance.