### aakarsh's blog

By aakarsh, history, 4 months ago, ,

For the problem : https://codeforces.com/problemset/problem/1280/C My submission is giving Runtime error on test 4. Exit code is 1. Please help me find my mistake. From what I understood reading other posts the exit code 1 is due to input issues but since I am getting it at test case 4 I don't know where is the problem.

def dfs(mat,subtree_sizes,p,v,good,bad,k):
for i in range(len(mat[p])):

x=mat[p][i][0]
d=mat[p][i][1]

if v[x]==0:
v[x]=1
good[0]+=d*(subtree_sizes[x]%2)
subtree_sizes[p]+=subtree_sizes[x]

return 0

for _ in range(int(input())):

k=int(input())

mat=[[] for i in range(2*k)]
v=[0 for i in range(2*k)]
subtree_sizes=[1 for i in range(2*k)]
good=[0]

for j in range(2*k-1):
a,b,d=map(int,input().split())
mat[a-1].append((b-1,d))
mat[b-1].append((a-1,d))
v[0]=1