PAT 1107 Social Clusters】的更多相关文章

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 their hobbies in common. You are supposed to find all…
PAT甲级1107. Social Clusters 题意: 当在社交网络上注册时,您总是被要求指定您的爱好,以便找到一些具有相同兴趣的潜在朋友.一个"社会群体"是一群拥有一些共同兴趣的人.你应该找到所有的集群. 输入规格: 每个输入文件包含一个测试用例.对于每个测试用例, 第一行包含一个正整数N(<= 1000),一个社交网络中的总人数.因此,人数从1到N.然后N行跟随,每个给出一个人的爱好列表的格式: Ki:hi [1] hi [2] ... hi [Ki] 其中Ki(>…
本文同步发布在CSDN:https://blog.csdn.net/weixin_44385565/article/details/90409731 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 …
1107 Social Clusters 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 their hobbies in common. Y…
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 their hobbies in com…
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 their hobbies in common. Yo…
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 their hobbies in common. You are supposed to fi…
简单并查集. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #include<map> #include<queue> #include<stack> #include<algorithm> using namespace std; +; int fa[maxn]; int num[maxn]; int n; vector…
题意:有n个人,每个人有k个爱好,如果两个人有某个爱好相同,他们就处于同一个集合.问总共有多少个集合,以及每个集合有多少人,并按从大到小输出. 很明显,采用并查集.vis[k]标记爱好k第一次出现的人的编号,如果为0则表示未出现. 当前第i个人若也存在爱好k,则只要将i与vis[k]两个人合并即可. 最后father[i]相同的即处在同一个集合中. #include <iostream> #include <cstdio> #include <algorithm> #i…
题意: 输入一个正整数N(<=1000),表示人数,接着输入N行每行包括一个他的爱好数量:和爱好的序号.拥有相同爱好的人们可以默认他们在同一个俱乐部,输出俱乐部的数量并从大到小输出俱乐部的人数(不同俱乐部的两个人的爱好一定不相同). AAAAAccepted code: #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; vector<],st; ]; ]; int find_(int…