![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
并查集
努力写题的tyf
这个作者很懒,什么都没留下…
展开
-
Rochambeau
N children are playing Rochambeau (scissors-rock-cloth) game with you. One of them is the judge. The rest children are divided into three groups (it is possible that some group is empty). You don’t kn...原创 2018-04-14 17:49:10 · 386 阅读 · 0 评论 -
L2-007 家庭房产 - 并查集
给定每个人的家庭成员和其自己名下的房产,请你统计出每个家庭的人口数、人均房产面积及房产套数。输入格式:输入第一行给出一个正整数N(≤1000),随后N行,每行按下列格式给出一个人的房产:编号 父 母 k 孩子1 ... 孩子k 房产套数 总面积其中编号是每个人独有的一个4位数的编号;父和母分别是该编号对应的这个人的父母的编号(如果已经过世,则显示-1);k(0≤k≤5)是该人的...原创 2019-02-24 18:52:28 · 242 阅读 · 0 评论 -
1013 Battle Over Cities - 并查集
思路:简单并查集,就是我们不考虑一个城市的时候,可以排除它用并查集,看看最后有几堆,那么ans就是堆数-1,(要把这几堆连起来)犯傻的地方:(1)qwq我开始看题还在想,用并查集怎么把取消的那个城市相关操作取消掉qwq,我是个傻子吗???离线处理不就好了qwq(2)求堆数的时候还开了个vis数组,标记每个城市的父节点???若这个点没被标记,则ans++???直接看看有几个点他的...原创 2018-10-16 20:10:48 · 220 阅读 · 0 评论 -
牛客练习赛24 - AB
A - 石子阵列 - 排列组合链接:https://www.nowcoder.com/acm/contest/157/A来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 262144K,其他语言524288K64bit IO Format: %lld题目描述xb有m种石子,每种无限个,Ta想从这些石子中取出n个,并按顺序排列起来,为了好看,相邻的石...原创 2018-08-10 23:05:05 · 209 阅读 · 0 评论 -
Wireless Network - poj2236 - 并查集
Wireless NetworkTime Limit: 10000MS Memory Limit: 65536K Total Submissions: 37707 Accepted: 15607 DescriptionAn earthquake takes place in Southeast Asia. The ACM (Asia Cooperat...原创 2018-08-04 13:24:20 · 104 阅读 · 0 评论 -
poj1733 - Parity game - 并查集、离散化(详解)
Now and then you play the following game with your friend. Your friend writes down a sequence consisting of zeroes and ones. You choose a continuous subsequence (for example the subsequence from the t...原创 2018-05-01 20:47:17 · 205 阅读 · 0 评论 -
Zjnu Stadium - 带权并查集
In 12th Zhejiang College Students Games 2007, there was a new stadium built in Zhejiang Normal University. It was a modern stadium which could hold thousands of people. The audience Seats made a circl...原创 2018-04-19 19:51:17 · 181 阅读 · 0 评论 -
How Many Answers Are Wrong - 带权并查集(详解)
TT and FF are ... friends. Uh... very very good friends -________-b FF is a bad boy, he is always wooing TT to play the following game with him. This is a very humdrum game. To begin with, TT should w...原创 2018-04-19 19:42:02 · 719 阅读 · 0 评论 -
Dragon Balls
Five hundred years later, the number of dragon balls will increase unexpectedly, so it's too difficult for Monkey King(WuKong) to gather all of the dragon balls together. His country has N cities and ...原创 2018-04-07 13:45:30 · 453 阅读 · 0 评论 -
Cube Stacking
Farmer John and Betsy are playing a game with N (1 <= N <= 30,000)identical cubes labeled 1 through N. They start with N stacks, each containing a single cube. Farmer John asks Betsy to perform ...原创 2018-04-06 21:43:58 · 124 阅读 · 0 评论 -
Wireless Network
An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wireless network with the lap computers, but an unexpected aftershock attacked, all computers in the n...原创 2018-04-06 19:32:14 · 303 阅读 · 0 评论 -
食物链 - 并查集的两种解法(详解)
动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。 现有N个动物,以1-N编号。每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种。有人用两种说法对这N个动物所构成的食物链关系进行描述: 第一种说法是"1 X Y",表示X和Y是同类。 第二种说法是"2 X Y",表示X吃Y。 此人对N个动物,用上述两种说法,一句接一句地说出K句话...原创 2018-04-12 21:51:59 · 6890 阅读 · 10 评论 -
超有爱的并查集~
转载自:点击打开链接例子就是杭电上的畅通工程:http://acm.hdu.edu.cn/showproblem.php?pid=1232首先在地图上给你若干个城镇,这些城镇都可以看作点,然后告诉你哪些对城镇之间是有道路直接相连的。最后要解决的是整幅图的连通性问题。比如随意给你两个点,让你判断它们是否连通,或者问你整幅图一共有几个连通分支,也就是被分成了几个互相独立的块。像畅通工程这题,问还需要修...转载 2018-04-06 11:31:36 · 158 阅读 · 0 评论 -
Find them, Catch them - 并查集
The 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 Gang Snake. However, the police first needs to identify which g...原创 2018-04-11 21:56:22 · 1266 阅读 · 1 评论 -
L2-013 红色警报 - 并查集
战争中保持各个城市间的连通性非常重要。本题要求你编写一个报警程序,当失去一个城市导致国家被分裂为多个无法连通的区域时,就发出红色警报。注意:若该国本来就不完全连通,是分裂的k个区域,而失去一个城市并不改变其他城市之间的连通性,则不要发出警报。输入格式:输入在第一行给出两个整数N(0 < N ≤ 500)和M(≤ 5000),分别为城市个数(于是默认城市从0到N-1编号)和连接两城市的...原创 2019-02-27 14:09:54 · 292 阅读 · 0 评论