hdu 2120 Ice_cream's world I
来源:互联网 发布:ubuntu搭建lamp 编辑:程序博客网 时间:2024/05/21 19:45
就是问有多少个圈,简单的并查集,没啥好说的,心塞不开心
#include<iostream>using namespace std;int mapp[1000+5];void s(){for(int i=0;i<1000+5;i++) mapp[i]=i;}int bfs(int x){if(x!=mapp[x]){mapp[x]=bfs(mapp[x]);}return mapp[x];}int main(){int n,m;while(cin>>n>>m){s(); int sum=0;while(m--){int x,y;cin>>x>>y;x=bfs(x);y=bfs(y);if(x==y) sum++;else mapp[x]=y;}cout<<sum<<endl;}return 0;}
0 0
- hdu 2120 Ice_cream's world I
- HDU 2120 Ice_cream's world I
- hdu 2120 Ice_cream's world I
- hdu-2120-Ice_cream's world I
- hdu 2120 Ice_cream's world I
- hdu 2120 Ice_cream's world I
- HDU-2120-Ice_cream's world I
- HDU 2120 Ice_cream's world I
- hdu-2120 Ice_cream's world I
- hdu 2120 Ice_cream's world I
- hdu 2120 Ice_cream's world I
- HDU 2120 Ice_cream's world I
- HDU 2120 Ice_cream's world I
- hdu 2120 Ice_cream's world I
- hdu 2120 (Ice_cream's world I)
- 【HDU 2120 Ice_cream's world I】
- HDU 2120Ice_cream's world I
- HDU-2120 Ice_cream's world I
- centos上搭建ftp服务
- 解决IE不能加载OCX控件问题(二)
- ubuntu 截图
- matlab常用函数积累
- HDU 1501 Zipper
- hdu 2120 Ice_cream's world I
- 【高性能MySQL】读书摘录2-第三章、服务器性能剖析
- 小马激活工具激活系统后,电脑不能启动,出现错误 a disk read error occurred
- NGUI控件说明(中文) UIKeyBinding
- 虚函数继承与虚继承
- r语言自带数据包
- 计划
- 图片上传预览功能实现
- android EditText输入限制