Ice_cream's world I
Ice_cream's world I
Time Limit : 3000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other)
Total Submission(s) : 1 Accepted Submission(s) : 1
#include<stdio.h>
int wall[];
int find(int x){
int r=x;
while(r!=wall[r])r=wall[r];
int i=x,j;
while(i!=r)j=wall[i],wall[i]=r,i=j;
return r;
}
int main(){
int N,M,temp1,temp2,f1,f2,flot;
while(~scanf("%d%d",&N,&M)){
for(int i=;i<N;++i)wall[i]=i;
flot=;
while(M--){
scanf("%d%d",&temp1,&temp2);
f1=find(temp1);f2=find(temp2);
if(f1!=f2)wall[f1]=f2;
else flot++;
}
printf("%d\n",flot);
}
return ;
}
Ice_cream's world I的更多相关文章
- A - Ice_cream’s world III
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Status Pract ...
- hdu 2120 Ice_cream's world I
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2120 Ice_cream's world I Description ice_cream's worl ...
- HDU 2121 Ice_cream’s world II 不定根最小树形图
题目链接: 题目 Ice_cream's world II Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Ja ...
- hdoj 2120 Ice_cream's world I【求成环数】
Ice_cream's world I Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...
- hdoj 2122 Ice_cream’s world III
并查集+最小生成树 Ice_cream’s world III Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 ...
- Ice_cream’s world III--2122
Ice_cream’s world III Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Ot ...
- Ice_cream's world I--hdu2120
Ice_cream's world I Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...
- Ice_cream’s world III(prime)
Ice_cream’s world III Time Limit : 3000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Othe ...
- hdoj 2121 Ice_cream’s world II 【没有最低树的根节点】
称号:pid=2121" target="_blank">hdoj 2121 Ice_cream's world II 题意:题目是一道躶题,给n个点,m条边的有向 ...
随机推荐
- 创建UILabel
UILabelCreate.h #import <UIKit/UIKit.h> @interface UILabelCreate : UILabel /** * 创建UILabel 初始化 ...
- class、interface、struct的差别
1 struct和class有什么差别 1.1默认的继承訪问权限 Struct是public的,class是private的. 你能够写例如以下的代码: struct A { char a; }; s ...
- mbed OS - ARM关于物联网(IoT)的战略布局
关于IoT 在刚刚过去的ARMTECHCON2014(Santa Clara Convention Center)第1天会议,首要的keynote就是ARM针对建立物联网(InternetOf Thi ...
- Android应用程序内部启动Activity过程(startActivity)的源代码分析
文章转载至CSDN社区罗升阳的安卓之旅,原文地址:http://blog.csdn.net/luoshengyang/article/details/6703247 上文介绍了Android应用程序的 ...
- 【HDU】 1018 Big Number
大意就是求 : log10(n!) = log10(1 * 2 * 3 * .......*n) = log10(1) + log10(2) + ........+log10(n); 打表的话会ML ...
- 包含深度学习常用框架的Docker环境
相关的代码都在Github上,请参见我的Github,https://github.com/lijingpeng/deep-learning-notes 敬请多多关注哈~~~ All in one d ...
- 虚拟化之docker安装篇
1,docker pull centos 下载centos镜像 docker search centos 搜索镜像 2,docker images 查看本地镜像 3,do ...
- XML读写
private string fileName = HttpContext.Current.Server.MapPath("~/Student.xml"); protected v ...
- iOS archive(归档)的总结
http://www.cnblogs.com/ios8/p/ios-archive.html
- “有箭头的视图”,即程序的Storyboard Entry Point。
设置方法很简单:打开StoryBoard文件,选中要设置为第一视图的ViewController,在右边工具栏勾选Is Initial View Controller就好了,此时你会看到ViewCon ...