C2. Party
来源:互联网 发布:汉诺塔问题算法 编辑:程序博客网 时间:2024/04/30 04:19
题意:额,只要注意each的意思
做法:基本的并查集技术,只要理解了each的意思...
#include<cstdio>#define LMT 2002using namespace std;int get[LMT],fs,father[LMT];int work(int u){ int x=u; while(x!=father[x]) x=father[x]; father[u]=x; return x;}int main(void){ int i,n,k,m,u,v,a,b,ans; scanf("%d",&n); scanf("%d",&k); for(i=1;i<=n;i++) { get[i]=1; father[i]=i; } while(k--) { scanf("%d%d",&u,&v); a=work(u);b=work(v); if(a!=b) { get[a]+=get[b]; father[b]=a; } } scanf("%d",&m); while(m--) { scanf("%d%d",&u,&v); a=work(u);b=work(v); if(a==b)get[a]=0; } ans=0; for(i=1;i<=n;i++) if(i==work(i)&&ans<get[i]) ans=get[i]; printf("%d\n",ans); return 0;}
- C2. Party
- c2
- C2
- c2
- C2
- c2
- C2
- Party
- Party
- Party
- Party
- Party
- C2-2
- Objective-C2
- my c2
- C2 的新世界
- C2.4用软件
- 新C2打码招工友
- C++类模板实现数据结构——栈
- 十道海量数据处理面试题与十个方法大总结
- A SOAP Example in Java
- Android初级开发第六讲--Activity的布局
- 这么多技术我该怎么学
- C2. Party
- Android 实现 选择文件对话框
- 字符串Hash算法
- LinkedList实现
- 如何在调用WCF服务之前弹出一个确认对话框?
- js一百零一夜之第二夜-js获取外部css样式
- 最近看到或是总结的一些观点
- HOJ 1496 World Cup Noise
- 《代码大全》读书笔记三