Can anyone please tell me what is wrong in this Python3 code for Kickstart 
Round C Problem 2 (Stable Wall) 

Link: 
https://codingcompetitions.withgoogle.com/kickstart/round/000000000019ff43/00000000003379bb

def dfs(visited, graph, node):
if node not in visited:
print(node, end = "")
visited.add(node)
for neighbour in graph[node]:
dfs(visited, graph, neighbour)

for case in range(1, int(input()) +1):
visited = set()
flag= 0
r,c = [int(x) for x in input().split()]
mat = []
char = []
char = set()
for i in range(r):
li = list(input())
mat.append(li)
for i in li:
char.add(i)
#print(char)
#print(mat)
pairs = []
pairs = set()
for i in range(r-1):
for j in range(c):
if mat[i][j] != mat[i+1][j] and (mat[i][j], mat[i+1][j]) not in pairs:
pairs.add((mat[i][j], mat[i+1][j]))
if (mat[i+1][j], mat[i][j]) in pairs:
print("Case #{}: -1".format(case))
flag = 1
break
if flag == 1:
break
if flag == 0:
#print(pairs)
with_edge = []
adj = {}
for i in char:
adj[i] = []
                for pair in pairs:
adj[pair[1]].append(pair[0])
with_edge.append(pair[0])
#print(adj)
for i in char:
if i in char and i not in with_edge:
start = i
#print(start)
print("Case #{}: ".format(case), end = "")
dfs(visited, adj, start)
print()

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-code+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/8b5998d7-3579-4869-ab96-bb1b860dce50%40googlegroups.com.

Reply via email to