摘要:
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1272这是一个并查集题,看似很水,其实陷阱也有很多,尤其是有了垃圾数据0 0,- -注意几个地方:(1)0 0输出Yes;(2),可能不是连通图,所以要判断是否连通,不连通No;(3),可能不是每个点都出现,比如最大点4,只出现了1 2 4,所以要注意标记。#include <stdio.h>#include <string.h>#include <algorithm>#include <string>#include <iostream> 阅读全文