随笔分类 -  ACM---并查集

摘要:n个点最少要n-1条边才能连通,可以删除一条边,最多删除2条边,然后枚举删除的1条边或2条边,用并查集判断是否连通,时间复杂度为O(n^3) 这边犯了个错误, for(int i=0;i<N;i++){ fa[i]=i; } 这个将i<=N,导致错误,值得注意 AC代码: 1 #pragma com 阅读全文
posted @ 2016-02-26 21:40 UniqueColor 阅读(443) 评论(0) 推荐(0) 编辑
摘要:Problem Description There is a tree(the tree is a connected graph which contains n points and n−1 edges),the points are labeled from 1 to n,which edge 阅读全文
posted @ 2016-01-28 00:39 UniqueColor 阅读(228) 评论(0) 推荐(0) 编辑
摘要:Problem DescriptionLuxer is a really bad guy. He destroys everything he met. One day Luxer went to D-city. D-city has N D-points and M D-lines. Each D... 阅读全文
posted @ 2015-11-25 18:12 UniqueColor 阅读(168) 评论(0) 推荐(0) 编辑
摘要:题目大意:给你N台电脑,从1-N。一个数字,表示两台计算机的最大通信距离,超过这个距离就无法进行通信。然后分别告诉这些电脑的坐标,接下来有两种操作,第一种O表示这点电脑修好,第二种S,表示测试这两台电脑能不能进行正常的通信解题思路:并查集的简单应用,对每次修好的电脑对其它已经修好的电脑遍历,如果距离... 阅读全文
posted @ 2015-11-07 15:48 UniqueColor 阅读(204) 评论(0) 推荐(0) 编辑
摘要:2.解题思路:本题利用欧拉回路存在条件解决。可以将所有的单词看做边,26个字母看做端点,那么本题其实就是问是否存在一条路径,可以到达所有出现过的字符端点。由于本题还要求了两个单词拼在一起的条件是前一个单词的右端点和本单词的左端点一样。所以这是一个有向图。根据结论:有向图的底图(忽略边的方向后的图)必... 阅读全文
posted @ 2015-09-25 23:39 UniqueColor 阅读(271) 评论(0) 推荐(0) 编辑
摘要:DescriptionBessie has been hired to build a cheap internet network among Farmer John's N (2 3 #include 4 #include 5 #include 6 #include 7 #include 8 ... 阅读全文
posted @ 2015-09-17 21:31 UniqueColor 阅读(250) 评论(0) 推荐(0) 编辑
摘要:Problem DescriptionWith the 60th anniversary celebration of Nanjing University of Science and Technology coming soon, the university sets n tourist sp... 阅读全文
posted @ 2015-09-17 11:29 UniqueColor 阅读(146) 评论(0) 推荐(0) 编辑
摘要:Problem DescriptionJack likes to travel around the world, but he doesn’t like to wait. Now, he is traveling in the Undirected Kingdom. There are n cit... 阅读全文
posted @ 2015-09-13 19:40 UniqueColor 阅读(196) 评论(0) 推荐(0) 编辑
摘要:Problem DescriptionFive hundred years later, the number of dragon balls will increase unexpectedly, so it's too difficult for Monkey King(WuKong) to g... 阅读全文
posted @ 2015-09-11 13:18 UniqueColor 阅读(180) 评论(0) 推荐(0) 编辑
摘要:题目描述DescriptionZ小镇是一个景色宜人的地方,吸引来自各地的观光客来此旅游观光。Z小镇附近共有N(1 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 #define inf 1... 阅读全文
posted @ 2015-09-06 19:05 UniqueColor 阅读(1017) 评论(0) 推荐(0) 编辑
摘要:Problem DescriptionJohn are playing with blocks. There are N blocks (1 2 #include 3 #include 4 using namespace std; 5 #define N 30006 6 int fa[N]; 7 ... 阅读全文
posted @ 2015-09-01 22:09 UniqueColor 阅读(227) 评论(0) 推荐(0) 编辑
摘要:DescriptionThe police office in Tadu City decides to say ends to the chaos, as launch actions to root up the TWO gangs in the city, Gang Dragon and Ga... 阅读全文
posted @ 2015-08-30 13:19 UniqueColor 阅读(181) 评论(0) 推荐(0) 编辑
摘要:Problem DescriptionSoda has a bipartite graph withnvertices andmundirected edges. Now he wants to make the graph become a complete bipartite graph wit... 阅读全文
posted @ 2015-08-15 18:03 UniqueColor 阅读(410) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示