UESTC1490 Eight Puzzle 双向BFS

【vjudge】八数码问题 EightThe 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 pa 阅读详情
Eight Puzzle

 

Time Limit: 2000 ms Memory Limit: 65536 kB
Solved: 35 Tried: 665

 

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 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 call the missing tile 'x'; the object of the puzzle is to arrange the tiles so that they are ordered as:

1 2 3 4

5 6 7 8

9 10 11 12

13 14 15 x

where the only legal operation is to exchange 'x' with one of the tiles with which it shares an edge. As an example, the following sequence of moves solves a slightly scrambled puzzle:

1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4

5 6 7 8 5 6 7 8 5 6 7 8 5 6 7 8

9 x 10 12 9 10 x 12 9 10 11 12 9 10 11 12

13 14 11 15 13 14 11 15 13 14 x 15 13 14 15 x

r-> d-> r->

The letters in the previous row indicate which neighbor of the 'x' tile is swapped with the 'x' tile at each step; legal values are 'r','l','u' and 'd', for right, left, up, and down, respectively.

Not all puzzles can be solved; in 1870, a man named Sam Loyd was famous for distributing an unsolvable version of the puzzle, and
frustrating many people. In fact, all you have to do to make a regular puzzle into an unsolvable one is to swap two tiles (not counting the missing 'x' tile, of course).

In this problem, you will write a program for solving the less well-known 8-puzzle, composed of tiles on a three by three
arrangement. To simplify this problem, you should print the minimum steps only.

 

Input

You will receive a description of a configuration of the 8 puzzle. The description is just a list of the tiles in their initial positions, with the rows listed from top to bottom, and the tiles listed from left to right within a row, where the tiles are represented by numbers 1 to 8, plus 'x'. For example, this puzzle

1 2 3

x 4 6

7 5 8

is described by this list:

1 2 3 x 4 6 7 5 8

 

Output
You will print to standard output either the word ``unsolvable'', if the puzzle has no solution.Otherwise, output an integer which equals the minimum steps. If

 

Sample Input
1 2 x 4 5 3 7 8 6

 

Sample Output
2

 

Hint
Any violent algorithm may gain TLE. So a smart method is expected.
The data used in this problem is unofficial data prepared by hzhua. So any mistake here does not imply mistake in the offcial judge data.

 

Source
modified from South Central USA 1998
140次后终于AC。。。
原来这题求最少步数不能用A*,杯具。。。
只好用双向BFS
HDU2059龟兔赛跑-题解动态规划DP 龟兔赛跑<br />Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)<br />Total Submission(s): 3538    Accepted Submission(s): 1277<br /><br />Problem Description据说在很久很久以前,可怜的兔子经历了人生中最大的打击——赛跑输给乌龟后,心中郁闷,发誓要报仇雪恨,于是躲进了杭州下沙某农业园卧薪尝胆潜心修 阅读详情

相关推荐

环形m段最大子段和 题解动态规划DP

http://acm.hunnu.edu.cn/online/?action=problem&type=show&id=10581环形m段最大子段和Time Limit: 5000ms, Special Time Limit:15000ms, Memory Limit:65536KB Total submit users: 3, Accepted users: 3 Problem 10581 : No special judgementProblem description  我想你已经做出了一维的最大子段

魔神翼 3063

搜索与搜索剪枝3

链接:登录—专业IT笔试面试备考平台_牛客网 来源:牛客网 八数码 You will receive a description of a configuration of the 8 puzzle. The description is just a list of the tiles in their initial positions, with the rows listed from top to bottom, and the tiles listed from left to righ.

2926

【YOLO 系列】基于YOLO V8的智能车载交通标志识别系统【python源码+Pyqt5界面+数据集+训练代码】

本文详细介绍了基于YOLO V8构建智能车载交通标志识别系统的完整流程。从环境搭建、数据集准备、模型训练到PyQt5图形界面开发,提供了Python源码和实战代码,帮助开发者快速实现高精度、实时的交通标志检测应用,提升驾驶辅助系统的开发效率。

wdx012345的博客 974

八数码的八境界

八数码的八境界   研究经典问题,空说不好,我们拿出一个实际的题目来演绎。八数码问题在北大在线测评系统中有一个对应的题,题目描述如下: Eight Time Limit: 1000MS Memory Limit: 65536K Special Judge Description The 15-puzzl...

weixin_33719619的博客 324

FlightStream实战:如何用面元法在笔记本电脑上完成无人机气动分析(附NASA案例)

本文详细介绍了如何利用FlightStream面元法在笔记本电脑上高效完成无人机气动分析,包括其核心技术优势、NASA D8案例实战解析及高效工作流建立。FlightStream作为快速CFD分析工具,显著提升了早期设计阶段的迭代速度,适用于概念设计验证和多气动构型比较。

weixin_28363123的博客 267

全面分析总结解决Could not transfer artifact org.apache.maven.plugins等此类问题的方法

全面分析总结解决Could not transfer artifact org.apache.maven.plugins,Could not transfer artifact xxx from/to xxx等此类问题的方法

ccjjjjdff的博客 1万+

POJ 1077 Eight 【八数码问题、康托展开、双向BFS、反向BFS、打表】

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...

Code_U 354

手把手教你解决Kernel panic报错:init找不到的5种排查方法(附NFS挂载实战)

本文深入解析了Linux系统启动时出现“Kernel panic - not syncing: No working init found”报错的根本原因,并提供了五种系统性的排查方法。文章结合NFS挂载根文件系统的实战场景,详细阐述了从动态链接库依赖、内核引导参数、NFS权限配置、文件系统完整性到内核配置干扰的完整排查路径,帮助开发者快速定位并解决这一常见的系统启动故障。

weixin_29159995的博客 205

2015 UESTC 搜索专题F题 Eight Puzzle 爆搜

Eight Puzzle Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/contest/show/61 Description The 15-puzzle has been around for over 100 years; even if you don't know it ...

weixin_34259232的博客 294

多智能体协作的本质是中介者模式,不是多开Agent

多智能体系统并非简单启动多个Agent实例,而是一种受控的、可验证的动态交互过程。其核心原理在于解耦Agent间直接依赖,通过中央中介者统一管理任务分发、协议转换、状态协调与故障兜底。这种架构显著提升系统的可观测性、容错性与可维护性,技术价值体现在强一致性保障(如金融订单原子操作)与灵活自治平衡(如边缘设备轻量协同)。典型应用场景包括电商客服协同、工业巡检调度、飞书/微信多渠道智能服务等。OpenClaw与Hermes Agent正是这一范式的工程落地代表,分别体现强中介与弱中介两种演进路径。

weixin_34151004的博客 368

1999年-2022年 上市公司-企业劳动生产率数据(原始数据、代码、最终结果、参考文献)

上市公司企业劳动生产率数据集为企业和市场参与者提供了一个深入分析企业生产效率和劳动效益的工具。通过这些数据,企业可以不断探索创新的发展模式和管理方式,努力提高生产效率,为提升市场竞争力和盈利能力做出贡献。数据名称:上市公司-企业劳动生产率数据数据年份:1999-2022年数据来源:国泰安数据库1999年-2022年 上市公司-企业劳动生产率数据(原始数据、代码、最终结果、参考文献)

2401_84585615的博客 886

Eight POJ - 1077

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, a...

ML-M的博客 397

SRAM ECC原理与应用:从汉明码到高可靠嵌入式系统设计

在嵌入式系统与高可靠性计算领域,内存数据完整性是系统稳定运行的基石。软错误(Soft Error)由宇宙射线或芯片内部粒子引发,可能导致存储单元发生位翻转,进而引发程序跑飞或数据损坏。为应对这一物理层挑战,错误校验与纠正(ECC)技术应运而生,其核心原理基于扩展汉明码,通过增加校验位实现单错误纠正、双错误检测(SECDED)能力。这项技术通过硬件透明纠错,在提升系统可靠性的同时,几乎不影响访问性能。在汽车电子、工业控制及航空航天等对安全性要求极高的场景中,ECC已成为保障长期稳定运行的关键硬件机制。本文聚焦

weixin_28728265的博客 542

1077 Eight 八数码问题

<br />EightTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 11425 Accepted: 5073 Special Judge<br />DescriptionThe 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

hqd_acm的专栏 1556

scratch绘制四个三角形 2024年6月中国电子学会 图形化编程 scratch编程等级考试二级真题和答案解析

​ scratch绘制四个三角形 一、题目要求 2024年6月电子学会图形化编程Scratch等级考试二级真题 1、准备工作 1.保留默认角色小猫; 2.添加背景Stars。 2、功能实现 1 .隐藏角色小猫,设置画笔裙始位置为(0,0),画笔颜色为黄色,画笔的粗细为5; 2. 点击绿旗,绘制如下图所示图形,三角形的边长为50。 二、案例分析 1、角色分析 角色:小猫 2、背景分析 背景:Stars背景 3、前期准备 1. 保留默认的小猫不变 ​

青少年编程学习指导 1732

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

HDU-1043 逆向bfs 打表

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 sliding tiles, each with a number from 1 to 15 o...

刷题记录 322

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

刷紫书第三章习题(习题3-1到习题3-6)

习题3-1 Score UVA - 1585 There is an objective test result such as “OOXXOXXOOO”. An ‘O’ means a correct answer of a problem and an ‘X’ means a wrong answer. The score of each problem of this test is c

ccnuacmhdu的博客 4333

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

Eight (八数码 + 康拓展开式)

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...

自渡的博客 891

Aizu ALDS1_13_B 8 Puzzle(八数码问题入门 BFS)

The goal of the 8 puzzle problem is to complete pieces on 3×33×3 cells where one of the cells is empty space.In this problem, the space is represented by 0 and pieces are represented by integers from ...

UncleJokerly 946

poj 3221Diamond Puzzle(bfs+状压)

Diamond Puzzle Time Limit: 2000MS   Memory Limit: 131072K Total Submissions: 1394   Accepted: 762 Description A diamond puzzle is played on a tessellated hexagon like the

一点一滴,从不止步! 671

POJ 3155 Hard Life 最大密度子图

Hard Life Time Limit: 8000MS   Memory Limit: 65536K Total Submissions: 4345   Accepted: 1226 Case Time Limit: 2000MS

魔神翼 3911

HDU 4069 Squiggly Sudoku 数独DLX 福州网络赛

Squiggly Sudoku Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 644 Accepted Submiss

魔神翼 3900

HDU 3696 FZU 2006 -- Farm Game SPFA最长路 2010福州区域赛

Farm Game Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 62768/32768 K (Java/Others) Total Submission(s): 148 Accepted Submission(s): 65 Problem Description “Farm Game” is one of the m

魔神翼 3708

SOJ2113: 数字游戏题解动态规划DP

2113: 数字游戏Submit your solution     Discuss this problem     Best solutionsDescription 【问题描述】 丁丁最近沉迷于一个数字游戏之中。这个游戏看似简单,但丁丁在研究了许多天之后却发觉原来在简单的规则下想要赢得这个游戏并不那么容易。游戏是这样的,在你面前有一圈整数(一共n个),你要按顺序将其分为m个部分,各部分内的数字相加,相加所得的m个结果对10取模后再相乘,最终得到一个数k。游戏的要求是使你所得的k最大或者最小。 例如,对

魔神翼 3591

[SCOI2009]windy数 题解动态规划DP

[SCOI2009]windy数 Time Limit:1000MS  Memory Limit:165536KTotal Submit:162 Accepted:74 Descriptionwindy定义了一种windy数。 不含前导零且相邻两个数字之差至少为2的正整数被称为windy数。 windy想知道,在A和B之间,包括A和B,总共有多少个windy数? Input包含两个整数,A B。 Output一个整数。 Sample Input【输入样例一】 1 10 【输入样例二】 25 50

魔神翼 3431

POJ3662 Telephone Lines 二分+最短路

Telephone Lines Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3468   Accepted: 1245 Description Farmer John wants to set up a telephone line at his farm.

魔神翼 3201
上一篇: POJ 1077 Eight 八数码 A*搜索算法
下一篇: 百度之星趣味赛——AK咆哮体
power721
博客等级 码龄19年 176粉丝 135原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值