八数码问题 紫书上的简单搜索 渣渣好久才弄懂 #include<cstdio> #include<cstring> using namespace std; const int M = 1000003; int x[4] = { -1, 1, 0, 0}, y[4] = {0, 0, -1, 1}; int dis[M], h[M], s[M][9], e[9]; int aton(int a[]) { int t = 0; for(int i = 0; i < 9; +…
Bfs搜索 1.把棋盘直接作为状态: #include<iostream> #include<cstring> #include<queue> #include<cstdlib> using namespace std; ; ; int flag; struct Point{ int x,y; }; struct Node{ int board[Size][Size]; Point space; int step; }; , ,,,,,,,,}; ]={-,…
Eight Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 30127 Accepted: 13108 Special Judge Description The 15-puzzle has been around for over 100 years; even if you don't know it by that name, you've seen it. It is constructed with 15…
The 15-puzzle has been around for over 100 years; even if you don't know it by that name, you've seen it. It is constructed with 15 sliding tiles, each with a number from 1 to 15 on it, and all packed into a 4 by 4 frame with one tile missing. Let's…