解题思路:给出n个点,m条边(即题目中所说的两点之间相连的颜色) 询问任意两点之间由多少种不同的颜色连接 最开始想的时候可以用传递闭包或者并查集来做,可是并查集现在还不会做,就说下用传递闭包来做的这种--- 最开始想的时候用传递闭包,可是想到传递闭包只能判断两点是否连通,不能判断连通这两点的颜色是不是一样的,所以当时想再另外用一个数组来放两点之间的颜色,没有写出来---- 然后今天去翻了别人的代码,发现把传递闭包的d数组改成三维的就可以解决问题了(因为注意到n,m的值都很小,四重循环再加一个if…