【并查集判环】hdu 2120 Ice_cream's world I
来源:互联网 发布:flowchart.js演示 编辑:程序博客网 时间:2024/05/22 04:59
#include <stdio.h>#include <map>#include <math.h>#include <algorithm>#include <string>#include <string.h>#include <iostream>#define mm(a) memset(a, 0, sizeof(a))using namespace std;int father[1111];int findd(int x){ if(x != father[x]) father[x] = findd(father[x]); return father[x];}int main(){ int n, m; while(scanf("%d%d", &n, &m) != EOF) { for(int i = 0; i < n; i ++) father[i] = i; int cnt = 0; while(m--) { int a, b; scanf("%d%d", &a, &b); a = findd(a); b = findd(b); if(a != b) father[a] = b; else if(a == b) cnt ++; } printf("%d\n", cnt); } return 0;}
0 0
- 【并查集判环】hdu 2120 Ice_cream's world I
- Hdu oj 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 2120 Ice_cream's world I
- android 项目实训——通讯录(未完版)
- 通过 Tomcat Advanced I/O 获得高性能的 Ajax
- 在Android中如何使用SQLite
- 黑客文化简史
- LinkedList、ArrayList
- 【并查集判环】hdu 2120 Ice_cream's world I
- 方法区溢出
- java 四则运算 栈的实现
- 钱荒下银行理财收益率角逐:邮储银行垫底
- Android中版本兼容问题
- 从零开始学android<Button组件的使用.五.>
- 面试题集锦---BY算法导论小组
- Ruby中的注释
- 怎么写广告?-竞价广告的8条铁律