HDU 3567 Eight II(八数码 II)】的更多相关文章

HDU 3567 Eight II(八数码 II) /65536 K (Java/Others)   Problem Description - 题目描述 Eight-puzzle, which is also called "Nine grids", comes from an old game. In this game, you are given a 3 by 3 board and 8 tiles. The tiles are numbered from 1 to 8 and…
HDU 1043 Eight(八数码) 00 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)   Problem 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 slid…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1043 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 pack…
Eight II Time Limit: 2000ms Memory Limit: 65536KB This problem will be judged on HDU. Original ID: 356764-bit integer IO format: %I64d      Java class name: Main   Eight-puzzle, which is also called "Nine grids", comes from an old game. In this…
题意:就是八数码问题,给你开始的串和结束的串,问你从开始到结束的最短且最小的变换序列是什么 分析:我们可以预处理打表,这里的这个题可以和HDU1430魔板那个题采取一样的做法 预处理打表,因为八数码问题实际上是每个小块位置的变化,上面的数字只是用来标记位置的, 所以通过映射将初末序列进行置换就好了,然后因为每次的x字符的置换位置不一样 所以需要以123456789这个初始串打9遍表就好了733ms #include <iostream> #include <cstdio> #inc…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1043 题目描述: 3*3的格子,填有1到8,8个数字,还有一个x,x可以上下左右移动,问最终能否移动到12345678x的状态? hint:每一个3*3的格子从上到右,从左到右,一行一行读. 解题思路: 比较简单的八数码问题,大一暑假老师讲过,一直手懒脑懒并没有亲自尝试过.因为是多实例,先从12345678x的状态bfs出来所有可以到达的状态,并且记录下来路径.八数码最重要的就是保存状态,如果这个…
Eight POJ - 1077 HDU - 1043 八数码问题.用hash(康托展开)判重 bfs(TLE) #include<cstdio> #include<iostream> #include<queue> #include<cstring> using namespace std; ,,,,,,,,,}; ]; ][]; queue<int> q; //data[][9]存储上一个状态,data[][10]存储到这个状态的操作,dat…
HDU 1043 Eight 八数码问题(经典问题) 题意 经典问题,就不再进行解释了. 这里主要是给你一个状态,然后要你求其到达\(1,2,3,4,5,6,7,8,x\)的转移路径. 解题思路 这里有很多的解法,我这里是参考的学长给的题解,真的写的巨好啊!可惜不知道是哪位学长写的>︿<. 下面就是学长写的题解了,自己改动和增添了一点. 经典问题,解法有很多,我们先来计算一下八数码问题一共有多少种状态.八数码问题包含九个字符,这九个字符可以任意排列,也就是\(9! = 362880\).所以八…
题意  输出八数码问题从给定状态到12345678x的路径 用康托展开将排列相应为整数  即这个排列在全部排列中的字典序  然后就是基础的BFS了 #include <bits/stdc++.h> using namespace std; const int N = 5e5, M = 9; int x[4] = { -1, 1, 0, 0}; int y[4] = {0, 0, -1, 1}; int fac[] = {1, 1, 2, 6, 24, 120, 720, 5040, 40320…
在学习八数码A*搜索问题的时候须要知道下面几个点: Hash:利用康托展开进行hash 康托展开主要就是依据一个序列求这个序列是第几大的序列. A*搜索:这里的启示函数就用两点之间的曼哈顿距离进行计算就能够. 减枝:在八数码里.随意交换一个空行和一个位置的数字,这个八数码的逆序数是不变的,这样就能够依据眼下状态推断是否可达终点状态了. 第一次做这个题用的map进行哈希,结果果断超时.之后又写了LRJ书上的hash方法也超时了,最后仅仅能用康托展开了 具体请參考:[八数码的八重境地] http:/…