这题网上都是用DFS做的,我也不知道怎么用BFS做的。。。有个注意点,就是一步也走不动的时候,输出1Problem DescriptionThere is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can Read More
posted @ 2013-06-11 22:30 瓶哥 Views(175) Comments(0) Diggs(0) Edit
花3小时打上的注释,分享给大家。。 1 #include 2 #include 3 const int MAXR = 20; 4 const int MAXC = 310; 5 const int MAXN = MAXR * MAXC + MAXC; 6 const int INF = MAXR * 10; 7 8 int n, m; 9 int L[MAXN], R[MAXN], U[MAXN], D[MAXN]; 10 int C[MAXN], O[MAXN], S[MAXN], H[MAXR]; 11 int nodeNumber; 12 13 void ini... Read More
posted @ 2013-06-11 18:14 瓶哥 Views(294) Comments(0) Diggs(0) Edit
Problem DescriptionIgnatius被魔王抓走了,有一天魔王出差去了,这可是Ignatius逃亡的好机会.魔王住在一个城堡里,城堡是一个A*B*C的立方体,可以被表示成A个B*C的矩阵,刚开始Ignatius被关在(0,0,0)的位置,离开城堡的门在(A-1,B-1,C-1)的位置,现在知道魔王将在T分钟后回到城堡,Ignatius每分钟能从一个坐标走到相邻的六个坐标中的其中一个.现在给你城堡的地图,请你计算出Ignatius能否在魔王回来前离开城堡(只要走到出口就算离开城堡,如果走到出口的时候魔王刚好回来也算逃亡成功),如果可以请输出需要多少分钟才能离开,如果不能则输出-1 Read More
posted @ 2013-06-10 21:07 瓶哥 Views(212) Comments(0) Diggs(0) Edit
Problem DescriptionIgnatius had a nightmare last night. He found himself in a labyrinth with a time bomb on him. The labyrinth has an exit, Ignatius should get out of the labyrinth before the bomb explodes. The initial exploding time of the bomb is set to 6 minutes. To prevent the bomb from explodin Read More
posted @ 2013-06-10 21:06 瓶哥 Views(191) Comments(0) Diggs(0) Edit
1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <math.h> 4 #include <windows.h> 5 #define STACK_INIT_SIZE 20 6 #define STACKINCREMENT 10 7 8 typedef char ElemType; 9 typedef struct10 {11 ElemType *top;12 ElemType *base;13 int stacksize; 14 }sqStack;15 16 //创建一个栈 17 void Read More
posted @ 2013-06-10 14:26 瓶哥 Views(200) Comments(0) Diggs(0) Edit
1 #include <cstdio> 2 #include <conio.h> 3 #include <windows.h> 4 #define MaxSize 10 5 typedef int ElemType; //把int定义为ElemType 6 typedef struct 7 { 8 int *elem; 9 int length;10 int listsize; 11 }Sqlist;12 13 void initSqlist(Sqlist *L)14 {15 L->elem=(int*)malloc(MaxSize*sizeof(El Read More
posted @ 2013-06-10 14:25 瓶哥 Views(167) Comments(0) Diggs(0) Edit
1 #include <cstdio> 2 #include <windows.h> 3 #define MaxSize 10 4 void insertElem(int Sqlist[],int *len,int i,int x) 5 { 6 int t; 7 if(*len==MaxSize || i<1 || i>*len+1) //检测非法插入 8 { 9 printf("This insert is illegal\n");10 return; 11 }12 for(t=*len-1;t>... Read More
posted @ 2013-06-10 14:24 瓶哥 Views(113) Comments(0) Diggs(0) Edit
优先队列,这道题被坑了,心情不好。Problem DescriptionAngel was caught by the MOLIGPY! He was put in prison by Moligpy. The prison is described as a N * M (N, M 2 #include 3 #include 4 #include 5 #define MAX 200 6 using namespace std; 7 typedef struct node 8 { 9 int x,y;10 int move;11 12 }point;13 point ... Read More
posted @ 2013-06-09 21:07 瓶哥 Views(243) Comments(0) Diggs(1) Edit
网上的Dancing Links用L[R[x]] ← L[x], R[L[x]] ← R[x]来表示节点的删除用L[R[x]] ← x, R[L[x]] ← x来表示节点的复原搞的我一头雾水,其实就是修改双向链表的左右地址,自己写一个马上有一个深刻的理解了,不过表现的形式有点不一样。 1 #include 2 #include 3 const int MAX=10; 4 typedef struct node 5 { 6 int num; 7 struct node *left,*right; 8 }point; 9 point *head=(point*)malloc(... Read More
posted @ 2013-06-08 23:55 瓶哥 Views(151) Comments(0) Diggs(0) Edit
好吧,BFS用模版还是比较好理解的。这代码能AC- -Problem DescriptionYou're in space.You want to get home.There are asteroids.You don't want to hit them.InputInput to this problem will consist of a (non-empty) series of up to 100 data sets. Each data set will be formatted according to the following description, an Read More
posted @ 2013-06-07 23:44 瓶哥 Views(216) Comments(1) Diggs(0) Edit