HDU 4496 D-City
来源:互联网 发布:java大数据框架 编辑:程序博客网 时间:2024/06/07 14:22
2013年通化邀请赛D题
基础并查集
#include<bits/stdc++.h>using namespace std;int f[10020];int sum;int u[100020],v[100020],ans[100020];int find(int x){ if(f[x]!=x) f[x]=find(f[x]); return f[x];}void make(int a,int b){ int f1=find(a); int f2=find(b); if(f1!=f2) { f[f2]=f1; sum--; }}int main(){ int N,M; while(scanf("%d%d",&N,&M)==2) { for(int i=1;i<=M;i++) scanf("%d%d",&u[i],&v[i]); for(int i=0;i<N;i++) f[i]=i; sum=N; for(int i=M;i>=2;i--) { make(u[i],v[i]); ans[i-1]=sum; } ans[M]=N; for(int i=1;i<=M;i++) printf("%d\n",ans[i]); } return 0; }
0 0
- HDU 4496 D-City
- hdu 4496 D-City
- HDU 4496 D-City
- HDU 4496 D-City
- hdu 4496 D-City
- HDU 4496 D-City
- hdu 4496 D-City
- D-City(HDU 4496)
- HDU 4496 D-City 解题报告
- HDU 4496 D-City(并查集)
- hdu 4496 D-City 并查集
- HDU 4496 D-CITY(并查集)
- 【并查集】-HDU-4496-D-City
- HDU 4496 D-City(并查集)
- hdu 4496 D-City(并查集)
- 【HDU】4496 D-City 并查集
- HDU 4496--D-City 【并查集删边】
- hdu 4496 D-City 并查集
- JavaScript高级程序设计(第2版) 学习笔记:(一)js函数依赖性
- 第八章 用户界面(二)
- python的私有变量解析
- 文件管理功能
- android设计模式之模板方法模式
- HDU 4496 D-City
- 博弈问题及SG函数(经典)
- 【HDOJ】1096 A+B for Input-Output Practice (VIII)
- 马尔科夫过程及隐马尔科夫模型HMM
- 分数拆分
- HDU 2897巴什博弈变形
- Zoj 3629 Treasure Hunt IV
- String Matching(poj1580)
- Ubuntu 13.10 14.04 用sogou拼音输入法替换ibus