2012年2月12日

poj-1988 Cube Stacking **

摘要: 1 /* 2 * poj-1988 Cube Stacking.cpp 3 * 4 * Created on: 2012-2-12 5 * Author: LongDou 6 * 7 * 并查集: 8 * 每个节点有3个域:1、fa[x]:并查集中x的父节点 (fa[x]必压在x之下,但不一定直接相邻) 9 * 2、rank[x]:在x之下(不包括x)且在fa[x]之上(包括fa[x])的方块数10 * (如果直接记录x之下的总方块数,则每次合并都需更... 阅读全文

posted @ 2012-02-12 16:52 龙豆 阅读(335) 评论(0) 推荐(0)

poj-1182 食物链 **

摘要: 1 // poj1182.cpp 2 // 与 poj-1703 Find them, Catch them 思想类似, 只是多了一种状态,rank取值为0、1、2: 3 // 0 : x 与 fa[x] 同类 4 // 1 : x 被 fa[x] 吃 5 // 2 : x 吃 fa[x] 6 7 #include "stdafx.h" 8 #include <cstdio> 9 using namespace std;10 11 const int maxn = 50000 + 10;12 const int maxk = 100000 + 10;13 14 阅读全文

posted @ 2012-02-12 15:26 龙豆 阅读(246) 评论(0) 推荐(0)

导航