poj
DEMON_BY
这个作者很懒,什么都没留下…
展开
-
poj2488A Knight's Journey
标准dfs,注意跳出条件#include #include int xx[8] = {-2, -2, -1, -1, 1, 1, 2, 2}; int yy[8] = {-1, 1, -2, 2, -2, 2, -1, 1}; int map[26][26];char movex[30];int movey[30]={1};int m,p,q;void dfs(int x,i原创 2013-10-27 22:06:39 · 351 阅读 · 0 评论 -
poj 2524 并查集
很水的题,注意输出格式,冒号后面有一个空格 - -#include #define maxn 50000int father[maxn] ;int ans;int find (int x){while(father[x]!=x){x=father[x];}return x;}int lianjie(int x,int y){int r原创 2013-11-03 12:30:43 · 503 阅读 · 0 评论 -
poj 1611The Suspects 并查集
最后输出的时候注意遍历每一个数,求每一个数的祖先,如果和0一样就结果加一#include #include #define maxn 30000int father[maxn];int find (int x){while(father[x]!=x){x=father[x];}return x;}int lianjie(int x,int y)原创 2013-11-03 12:46:33 · 501 阅读 · 0 评论 -
poj1703并查集
#include #define maxn 330000int father[maxn],r[maxn];//r[x]表示该节点相对于根节点的位移量, int find(int x){int px;px=father[x];//记录父节点 if(father[x]==x)return father[x];else father[x]=find(father[x]);原创 2013-11-10 00:55:05 · 430 阅读 · 0 评论