Description
Problem A
The Most Distant State
Input: standard input
Output: standard output
The 8-puzzle is a square tray in which eight square tiles are placed. The remaining ninth square ...
分类:
其他好文 时间:
2014-06-10 07:59:06
阅读次数:
335
BFS+状态压缩,做了很多状态压缩了。今晚把八数码问题给搞定了。 1 #include 2
#include 3 #include 4 #include 5 using namespace std; 6 7 typedef struct node_st
{ 8 int x, y, ...
分类:
其他好文 时间:
2014-06-02 17:14:38
阅读次数:
232
题意:经典八数码问题
思路:HASH+BFS#include
#include
#include
#include
using namespace std;
const int MAXN = 500000;
const int size = 1000003;
typedef int State[9];
char str[30];
int state[9],goal[9]={1, 2, ...
分类:
其他好文 时间:
2014-05-24 21:46:23
阅读次数:
359
八数码0.0,我又来水博客了。
IDA*算法,A*为曼哈顿距离,判重用康拓展开。
#include
#include
#include
#include
#include
using namespace std;
int a[4][4];
int dx[]={0,0,-1,1};
int dy[]={-1,1,0,0};
char s[]="123804765";
int end[4]...
分类:
其他好文 时间:
2014-05-11 06:20:57
阅读次数:
334
1 /* 2
题意:八数码问题,给出3*3的矩阵含1~8以及x,给出一个符合的解使得移动后的矩阵的顺序为1~8,最后为x 3 4 题解:BFS 5
需要用到康托展开来表示状态,不然数组无法完全表示所有状态,这样BFS就无法判断找不到解的情况(status 6 的0ms,0KB究竟是怎...
分类:
其他好文 时间:
2014-05-05 22:34:16
阅读次数:
403