![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构
文章平均质量分 70
nw4869
i m just a kid
展开
-
POJ - 1182 食物链(并查集)
食物链Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 39572 Accepted: 11541Description动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。 现有N个动物,以1-N编号。每个动原创 2014-02-20 23:01:51 · 650 阅读 · 0 评论 -
POJ - 1703 Find them, Catch them (并查集2)
Find them, Catch themTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 27836 Accepted: 8486DescriptionThe police office in Tadu City decides to say ends t原创 2014-02-20 17:04:02 · 813 阅读 · 0 评论 -
并查集(Union-Find Set)
优化1:将遍历过的结点都改成树根的儿子优化2:记录树的高度,将小树连向大树//并查集int par[MAX], rak[MAX]; //父结点, 树的高度//初始化n个元素void init(int n){ for(int i = 0; i < n; i++) { par[i] = i; rak[i] = 0; }}//查询树的根int find(转载 2014-02-19 00:04:17 · 842 阅读 · 0 评论 -
POJ 3614 Sunscreen 优先队列
SunscreenTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 2952 Accepted: 1031DescriptionTo avoid unsightly burns while tanning, each of the C (1 ≤ C ≤ 25原创 2014-02-19 16:26:35 · 745 阅读 · 0 评论 -
ACMclub - 2131 产生冠军(拓扑排序,map)
题目连接1、成环矛盾2、不全在同一集合则无法产生冠军。#define _CRT_SECURE_NO_WARNINGS#include #include #include #include #include using namespace std;int N, M;const int MAXN = 1001, MAXM = MAXN*MAXN/2;int g[MAX原创 2014-03-01 17:24:15 · 761 阅读 · 0 评论 -
POJ - 2236 Wireless Network (并查集)
Wireless NetworkTime Limit: 10000MS Memory Limit: 65536KTotal Submissions: 14777 Accepted: 6224DescriptionAn earthquake takes place in Southeast Asia. The ACM (As原创 2014-02-20 13:41:39 · 946 阅读 · 0 评论 -
POJ 2010 - Moo University - Financial Aid (优先队列)
Moo University - Financial AidTime Limit: 1000MS Memory Limit: 30000KTotal Submissions: 4109 Accepted: 1257DescriptionBessie noted that although humans have many原创 2014-02-19 23:27:50 · 1192 阅读 · 0 评论 -
POJ - 2823 Sliding Window(单调队列RMQ)
http://poj.org/problem?id=2823先是用stl里的deque结果TLE了,然后手工实现deque,5000MS AC了#include using namespace std;const int MAX_N = 1e6+1;int N, K;int a[MAX_N];int que[MAX_N][2], front, tail;void insert(原创 2014-03-05 11:12:25 · 709 阅读 · 0 评论 -
GUETOJ - 1101 Forming Teams(并查集2)
http://acm.guet.edu.cn/problemset/problem/1101same(x, y):在同一队伍里。unite(x, y+N), unite(x+N, y):将2者安排到不同的队伍里。只需判断是否在已推断出在同一队伍里,产生矛盾,则它必须坐板凳。另外有一点需要注意的是队伍双方的 人数必须相等,否则要有人坐板凳,即ans++;#include #in原创 2014-03-06 21:17:05 · 904 阅读 · 0 评论