12 条题解
-
0罗昊2003 LV 9 @ 2017-02-01 20:00:33
#include <iostream>
#include <algorithm>
using namespace std;
int n,f[1001],tot,s[1001],k;
int getf(int n)
{
if(f[n]==n)
return n;
else f[n]=getf(f[n]);
return f[n];
}
void merge(int a,int b)
{
int c=getf(a),d=getf(b);
if(c!=d) f[d]=c;
}
int cmp(int a,int b)
{return a>b;
}
int main()
{
cin>>n>>k;
for(int i=1;i<=n;i++) f[i]=i;
for(int i=1;i<=n;i++)
{
int t,j;
cin>>j;
for(int e=1;e<=j;e++)
{
cin>>t;
merge(t,i);
}
}
for(int i=1;i<=n;i++)
{
s[f[i]]++;
}
sort(s+1,s+n,cmp);
for(int i=1;i<=k;i++) {
tot+=s[i];}
cout<<tot;
}
求救啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊 -
02017-02-01 19:58:38@
求救
-
02017-02-01 19:58:29@
编译成功
测试数据 #0: WrongAnswer, time = 0 ms, mem = 740 KiB, score = 0
测试数据 #1: WrongAnswer, time = 0 ms, mem = 740 KiB, score = 0
测试数据 #2: WrongAnswer, time = 0 ms, mem = 744 KiB, score = 0
测试数据 #3: WrongAnswer, time = 0 ms, mem = 740 KiB, score = 0
测试数据 #4: WrongAnswer, time = 93 ms, mem = 740 KiB, score = 0
测试数据 #5: WrongAnswer, time = 0 ms, mem = 744 KiB, score = 0
测试数据 #6: WrongAnswer, time = 125 ms, mem = 740 KiB, score = 0
测试数据 #7: Accepted, time = 0 ms, mem = 744 KiB, score = 10
测试数据 #8: WrongAnswer, time = 218 ms, mem = 744 KiB, score = 0
测试数据 #9: WrongAnswer, time = 15 ms, mem = 740 KiB, score = 0
WrongAnswer, time = 451 ms, mem = 744 KiB, score = 10 -
02009-11-14 13:16:03@
这题是搜索吗?
-
02009-11-13 17:13:31@
orz为什么用链表过不了……
-
02009-11-13 17:09:18@
otz
-
02009-11-13 16:59:30@
谁给个数据。。
我202不知道为什么…………………… -
02009-11-13 16:55:14@
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
├ 测试数据 05:答案正确... 0ms
├ 测试数据 06:答案正确... 0ms
├ 测试数据 07:答案正确... 0ms
├ 测试数据 08:答案正确... 0ms
├ 测试数据 09:答案正确... 0ms
├ 测试数据 10:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:0ms我无耻地来贴个秒杀的AC记录...
-
02009-11-13 16:48:18@
占地盘
-
02009-11-13 16:21:32@
....
-
02009-11-07 01:52:15@
板凳……
初音比赛第一题……
听说题目背景很雷人…… -
02009-11-07 01:16:37@
沙发。哇哈哈。
- 1