上一页 1 ··· 30 31 32 33 34

2012年7月19日

hdu 1325 Is It A Tree?

摘要: 题目链接 #include"stdio.h"int set[1001],v[1001],cnt[10001],flag;//初始化void fun(){ int i; flag=1; for(i=1;i1) t++;//t计算根节点数目 if(t!=1) return -1; els... 阅读全文

posted @ 2012-07-19 19:34 Slege 阅读(96) 评论(0) 推荐(0) 编辑

hdu 1856 More is better

摘要: 题目链接 #include"stdio.h"int set[10000001],sum[10000001],ans,max;int find(int x){ int r,i; r=x; while(r!=set[r]) r=set[r]; while(x!=set[x]) { i=s... 阅读全文

posted @ 2012-07-19 19:34 Slege 阅读(59) 评论(0) 推荐(0) 编辑

hdu 1116 Play on Words

摘要: 点击打开链接 简单欧拉回路判定: 当是单向欧拉回路时,必须保证每个结点入度等于出度。 当是单向欧拉路时,必须保证除了两个结点外,每个结点的入度等于出度,但这两个结点中,一个结点的入度比出度大1,另一个结点的入度比出度小1。 #include#includeint IN[30],OUT[30... 阅读全文

posted @ 2012-07-19 19:34 Slege 阅读(70) 评论(0) 推荐(0) 编辑

hdu 1829 A Bug's Life

摘要: 两种代码 1: /*以往的并查集题目是读入的是相同的,这和题目读入的是不同的用set[]数组来判断*/#include"stdio.h"#include"string.h"int set[2010],v[2010];int find(int x){ int r=x; while(r!=set[... 阅读全文

posted @ 2012-07-19 19:34 Slege 阅读(100) 评论(0) 推荐(0) 编辑

poj 1182 食物链

摘要: 点击打开链接 #include /* father[x]表示x的根节点 */int father[50005]; /*rank[x]表示father[x]与x的关系rank[x] == 0 表示father[x]与x是同类rank[x] == 1 表示x吃father[x]rank[x]... 阅读全文

posted @ 2012-07-19 19:33 Slege 阅读(114) 评论(0) 推荐(0) 编辑

poj 1703 Find them, Catch them

摘要: 题目链接:http://poj.org/problem?id=1703 题目大意:警察抓获N个罪犯,这些罪犯只可能属于两个团伙中的一个,现在给出M个条件(D a b表示a和b不在同一团伙),对于每一个询问(A a b)确定a,b是不是属于同一团伙或者不能确定。 思路:一般的并查集题目都是给出a,... 阅读全文

posted @ 2012-07-19 19:33 Slege 阅读(84) 评论(0) 推荐(0) 编辑

hdu 1198 Farm Irrigation

摘要: 点击打开链接 关键在于如何建图,如何找到相连关系。对每张图片分析就会知道,每块地的水管都是在中间,分为上、下、左、右四个方向可以通水,分两种模式,一种水平相邻,一种竖直相邻,判断他们能不能相通,先预处理得到每两个字符所代表的土地的关系,读入数据后,对应处理,将每块地都编一个标号,就抽象出并查集模... 阅读全文

posted @ 2012-07-19 19:33 Slege 阅读(69) 评论(0) 推荐(0) 编辑

hdu 2717 Catch That Cow

摘要: 点击打开链接 /* 自己做的第一个广搜。。 一次AC */ #include"stdio.h"#include"string.h"#include"queue"using namespace std;int n,k,map[100001];struct node{ int x,step;};i... 阅读全文

posted @ 2012-07-19 19:33 Slege 阅读(88) 评论(0) 推荐(0) 编辑

hdu 1240 Asteroids!

摘要: 三维的广搜。。 #include#include#define Maxn 15char map[Maxn][Maxn][Maxn];int N,A,B,C,D,E,F;char start[Maxn];char end[Maxn];int move[6][3]={{1,0,0},{-1,0... 阅读全文

posted @ 2012-07-19 19:32 Slege 阅读(97) 评论(0) 推荐(0) 编辑

上一页 1 ··· 30 31 32 33 34

导航