第二题做的dfs,怎么都调不对,有没有大佬帮忙看看 n, k = (int(x) for x in input().split()) colors = input() edges = [[] for _ in range(n)] for _ in range(n-1): u, v = (int(x) for x in input().split()) u, v = u-1, v-1 edges[u].append(v) edges[v].append(u) cnt = [-1] * n def dfs(u, f=-1): tmp = 0 ...