并查集
多一些不为什么的坚持
qq:1216161552
展开
-
排座位(天梯赛初赛)
布置宴席最微妙的事情,就是给前来参宴的各位宾客安排座位。无论如何,总不能把两个死对头排到同一张宴会桌旁!这个艰巨任务现在就交给你,对任何一对客人,请编写程序告诉主人他们是否能被安排同席。输入格式:输入第一行给出3个正整数:N(\le≤100),即前来参宴的宾客总人数,则这些人从1到N编号;M为已知两两宾客之间的关系数;K为查询的条数。随后M行,每行给出一对宾客之间的关系,格式为:宾原创 2017-03-13 18:23:30 · 2559 阅读 · 0 评论 -
L2-4 部落 (并查集)
在一个社区里,每个人都有自己的小圈子,还可能同时属于很多不同的朋友圈。我们认为朋友的朋友都算在一个部落里,于是要请你统计一下,在一个给定社区中,到底有多少个互不相交的部落?并且检查任意两个人是否属于同一个部落。输入格式:输入在第一行给出一个正整数NN(\le 10^4≤104),是已知小圈子的个数。随后NN行,每行按下列格式给出一个小圈子里的人:KK P[1]P[原创 2017-05-14 17:17:22 · 1670 阅读 · 0 评论 -
1107. Social Clusters (30) 并查集
When register on a social network, you are always asked to specify your hobbies in order to find some potential friends with the same hobbies. A "social cluster" is a set of people who have some of th原创 2017-07-31 22:05:37 · 194 阅读 · 0 评论 -
1114. Family Property (25) <并查集,set>
This time, you are supposed to help us collect the data for family-owned property. Given each person's family members, and the estate(房产)info under his/her own name, we need to know the size of each f原创 2017-08-03 12:30:29 · 260 阅读 · 0 评论 -
1118. Birds in Forest (25) <并查集+set>
Some scientists took pictures of thousands of birds in a forest. Assume that all the birds appear in the same picture belong to the same tree. You are supposed to help the scientists to count the maxi原创 2017-08-04 14:26:06 · 479 阅读 · 0 评论 -
1004. Counting Leaves (30)
A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child.InputEach input file contains one test case. Each case starts with原创 2017-06-10 21:30:00 · 262 阅读 · 0 评论