Python 3-Checker Log Exit code is 1

Revision en1, by aakarsh, 2020-01-28 21:52:50

For the problem : https://codeforces.net/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
			dfs(mat,subtree_sizes,x,v,good,bad,k)
			bad[0]+=d*min(subtree_sizes[x],2*k-subtree_sizes[x])
			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]
	bad=[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
	dfs(mat,subtree_sizes,0,v,good,bad,k)

	print(good[0],bad[0])

69686192

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English aakarsh 2020-01-28 21:52:50 1114 Initial revision (published)