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 ...
随机推荐
- ZOJ Problem Set - 2563 Long Dominoes 【如压力dp】
称号:ZOJ Problem Set - 2563 Long Dominoes 题意:给出1*3的小矩形.求覆盖m*n的矩阵的最多的不同的方法数? 分析:有一道题目是1 * 2的.比較火.链接:这里 ...
- 座IO理解力
一般堵塞IO服务器通信,通常有一个单独的Acceptor线程负责监控client联系,它接收client对于每个请求连接后client分配用于处理一个新的线程,处理后.返回应答给client.线程才销 ...
- V微软S2015下载:开展Win10/Linux/iOS多平台软件
微软VS2015下载:开展Win10/Linux/iOS多平台软件 资源:IT之家作者:子非 责任编辑:子非 11月13日消息,微软刚刚宣布了 Visual Studio 2015 ...
- java通讯录
)设一个通信录由以下几项数据信息构成: 数据项 类型 姓名 字符串 地址 字符串 邮政编码 ...
- hbase开放lzo压缩
hbase仅仅支持对gzip的压缩,对lzo压缩支持不好. 在io成为系统瓶颈的情况下,一般开启lzo压缩会提高系统的吞吐量. 但这须要參考详细的应用场景,即是否值得进行压缩.压缩率是否足够等等. ...
- iOS开发- Xcode插件(一)-规范凝视生成器VVDocumenter
分享几个经常使用的Xcode插件. 第一个, 规范凝视生成器VVDocumenter. 顾名思义, 它能够非常方便的为你自己主动加入�凝视 使用效果例如以下: 下载链接:https://github. ...
- cocos2d-html5
cocos2d-html5 简单的混乱 在正常情况下,build设置完毕后 跑ant编 变更后cocos2d.js 简单直观so easy 只需要上传cocos2d.js/game.js/index文 ...
- 【Android进阶】URL与URI的区别
首先,URI,是uniform resource identifier,统一资源标识符,用来唯一的标识一个资源. 而URL是uniform resource locator,统一资源定位器,它是一种具 ...
- C# - is
Checks if an object is compatible with a given type. An is expression evaluates to true if the pr ...
- 在eclipse中启动tomcat时报错:could not create java virtual machine... a fatal error...
控制台报错:unrecoginzed option: --launcher XXMaxPermSize 解决方法:-〉 perference -> tomcat ->JVM setting ...