
图论-并查集
LYoGa
这个作者很懒,什么都没留下…
展开
-
POJ1182食物链
http://hi.baidu.com/tomspirit/item/d1f2a19b2aaf36d27a7f0158http://cavenkaka.iteye.com/blog/1489588两个参考的博客。#include #include #include using namespace std;const int N = 50005;int f[N原创 2014-04-13 21:27:03 · 595 阅读 · 0 评论 -
UVA10397- Connect the Campus
#include #include #include #include #include #define N 600005using namespace std;struct state{ int l, r; double value; }s[N];int n, m, cnt, f[N], x[N], y[N];double sum;bool cmp原创 2014-04-14 16:28:49 · 569 阅读 · 0 评论 -
UVA10369- Arctic Network
#include #include #include #include #include #define N 250005using namespace std;struct state{ int l, r; double value;}s[N];int n, m, cnt, f[N], x[N], y[N];double ans;bool cmp(c原创 2014-04-14 16:24:21 · 594 阅读 · 0 评论 -
POJ2377
#include #include #include #include #define N 100005using namespace std;struct state{ int l, r, value;}s[N];int n, m, cnt;int f[N], sum;bool cmp(const state& a, const state& b) {原创 2014-04-14 16:30:29 · 664 阅读 · 0 评论 -
UVA10048- Audiophobia
#include #include #include #include #define N 10005using namespace std;struct state{ int l, r, value;}s[N];int n, m, f[N];int getFather(int x) { return x == f[x] ? x : f[x] = getF原创 2014-04-14 16:17:19 · 570 阅读 · 0 评论 -
UVA10099- The Tourist Guide
#include #include #include #include #define N 10005using namespace std;struct state{ int l, r, value;}s[N];int n, m, k, t, d, ans1, ans2;int f[N];bool cmp(const state& a, const state原创 2014-04-14 16:21:45 · 660 阅读 · 0 评论 -
UVA10158- War
本题的难处在于对于friends和enemries原创 2014-04-14 16:13:09 · 565 阅读 · 0 评论 -
UVA10608
计算出集合中元算#include #include #include #define N 30000using namespace std;int cas, n, m, ans;int father[N], cnt[N]; void init(int n) { for (int i = 1; i <= n; i++) { father[i] =原创 2014-04-14 16:03:44 · 626 阅读 · 0 评论 -
UVA11987- Almost Union-Find
#include #include #include #define N 100005using namespace std;int f[N * 2], cnt[N * 2], sum[N * 2];int n, m, a, b, k;void init() { for (int i = 1; i <= n; i++) { f[i] = i + n;原创 2014-04-14 16:00:07 · 610 阅读 · 0 评论 -
POJ1611
计算被感染人的数量,shui t#include #include #include using namespace std;const int N = 30005;int f[N], num[N], arr[N];int n, m;void init() { for (int i = 0; i < n; i++) { f[i] = i原创 2014-04-14 15:55:09 · 754 阅读 · 0 评论 -
POJ2524
并查集模版,水题#include #include #include using namespace std;const int N = 50005;int f[N];int n, m;void init() { for (int i = 1; i <= n; i++) f[i] = i; }int find(int x) { re原创 2014-04-13 22:00:15 · 753 阅读 · 0 评论