hdu More is better
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1856
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <iostream>
#include <ctype.h>
#include <iomanip>
#include <queue>
#include <stdlib.h>
using namespace std; int f[],num[];
int n,m; void init()
{
for(int i=;i<=;i++){
f[i]=i;
num[i]=;
}
} int find(int x)
{
if(x!=f[x])
f[x]=find(f[x]);
return f[x];
} void Union(int x,int y)
{
int p=find(x);
int q=find(y);
if(p != q){
f[p] = q;
num[q]+=num[p];
}
} int main()
{
int n,m,i,j,a,b;
while(~scanf("%d",&n)){
if(n==){
printf("1\n");
continue;
}
init();
int max=;
for(i=;i<n;i++){
scanf("%d%d",&a,&b);
Union(a,b);
}
for(j=;j<=;j++){
if(num[j]>max)
max=num[j];
}
printf("%d\n",max);
}
}
hdu More is better的更多相关文章
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 【HDU 3037】Saving Beans Lucas定理模板
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...
- hdu 4859 海岸线 Bestcoder Round 1
http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...
- HDU 4569 Special equations(取模)
Special equations Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- HDU 4006The kth great number(K大数 +小顶堆)
The kth great number Time Limit:1000MS Memory Limit:65768KB 64bit IO Format:%I64d & %I64 ...
- HDU 1796How many integers can you find(容斥原理)
How many integers can you find Time Limit:5000MS Memory Limit:32768KB 64bit IO Format:%I64d ...
- hdu 4481 Time travel(高斯求期望)(转)
(转)http://blog.csdn.net/u013081425/article/details/39240021 http://acm.hdu.edu.cn/showproblem.php?pi ...
- HDU 3791二叉搜索树解题(解题报告)
1.题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=3791 2.参考解题 http://blog.csdn.net/u013447865/articl ...
- hdu 4329
problem:http://acm.hdu.edu.cn/showproblem.php?pid=4329 题意:模拟 a. p(r)= R'/i rel(r)=(1||0) R ...
- HDU 2586
http://acm.hdu.edu.cn/showproblem.php?pid=2586 题意:求最近祖先节点的权值和 思路:LCA Tarjan算法 #include <stdio.h&g ...
随机推荐
- 无奈而又苦逼的二分版本号回退法定位新引入的bug!!!
昨天測试人员和开发者都发现, 某新版本号有严重的bug. 群里已经開始嚷嚷了, 但没有谁知道是谁引入的问题.本来呢, 这个问题不应该是由我去定位, 但主管让我帮定位一下, 毕竟时间太紧急, 必须尽快 ...
- POJ 2352 Stars 树阵
标题效果:特定y值在升序一些点.一个点的定义level值点的数目对于其左下,每个请求level多少分. 思维:因为y值它是按升序.所以分的差距仅仅是推断x值相比之前的大.就用树状数组维护. CODE: ...
- 计时器 Timer
计时器 Timer 不多说了,守则.
- Notification和Activity交互
概述 通知(Notification)就是程序在不影响用户操作的情况下,通过手机顶部弹出消息告诉用户的一种信息通知方式,而且能够通过下拉通知操作抽屉通知,实现Notification与活动.通知和服务 ...
- 【Java基础】“数三退一”问题的代码实现
现在有500个小孩,编号为0-499,手牵手连成一个圈,从第一个小孩开始"123123..."报数,数到三的小孩退出,求剩下的最后一个小孩的编号. public static vo ...
- ubuntu 下安装crypto
直接运行apt-get install python-crypto 就好了
- 自己主动机串标:Directed Acyclic Word Graph
trie -- suffix tree -- suffix automa 有这么几个情况: 用户输入即时响应AJAX搜索框, 显示候选名单. 搜索引擎keyword统计数量. 后缀树(Suffix T ...
- org.hibernate.MappingException: Could not determine type for: java.util.List, at table: user, for...
异常详情: Caused by: org.hibernate.MappingException: Could not determine type for: java.util.List, at ta ...
- 真实故事:网站遭遇DOS攻击
网站遭遇DOS攻击 一个.事件背景 长假对于IT人员来说是个短暂的休整时期,可IT系统却一时也不能停.越是节假日,越可能出大问题,以下要讲述的就是一起遭受DOS攻击的案例. 春节长假刚过完,小李 ...
- 第十二章——SQLServer统计信息(1)——创建和更新统计信息
原文:第十二章--SQLServer统计信息(1)--创建和更新统计信息 简介: 查询的统计信息: 目前为止,已经介绍了选择索引.维护索引.如果有合适的索引并实时更新统计信息,那么优化器会选择有用的索 ...