这题写得比较痛苦.首先有点不在状态,其次题目比较难读懂. “Gang”成立的两个条件:①成员数大于两个 ②边权总和大于阈值K 首先,在录数据的时候通过map或者字符串哈希建立string到int的映射. 然后,这个题的数据结构其实是带权无向图.在录数据的时候就要处理好点权和边权. 最后,对所有顶点做一遍dfs,汇总边权,找出最大点权和最大点权所在的点,把数据录进ans里. 注意的点一个是环路边权的汇总.方法是在dfs中通过先加边权再判断vis是否遍历过.此时又要注意用不搜前驱点的dfs结果,及…