摘要: http://poj.org/problem?id=1611思路:统计出和0能够联系在一起的点,然后输出其个数View Code #include <cstdio>#include <iostream>#define maxn 30004using namespace std;int f[maxn],num[maxn];//num记录与0有联系的个数int n,m;int find(int x){ if (x != f[x]) { f[x] = find(f[x]); } return f[x];}void Union(int x,int y){ x... 阅读全文
posted @ 2012-03-23 21:32 E_star 阅读(201) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=2299归并虽然知道了过程但是敲起代码来还是出现各种小错误。。。唉,,,View Code #include <cstdio>#include <iostream>#define maxn 500007using namespace std;int a[maxn];int n;int tmp[maxn];__int64 ct;void merge(int s,int m,int e){ int i = s,j = m + 1; int k = 0; while (i <= m && j <= 阅读全文
posted @ 2012-03-23 20:56 E_star 阅读(189) 评论(0) 推荐(0) 编辑