杭电 p1043 acm eight 八数码

本文主要探讨杭电ACM比赛中的P1043题目——八数码问题,它涉及到图论、路径搜索和数字交换等算法。题目要求在限定时间内找到解决方案,并提供了特殊判断标准。
摘要由CSDN通过智能技术生成

Eight

Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 1852    Accepted Submission(s): 532
Special Judge

Problem Description
The15-puzzle has been around for over 100 years; even if you don't know itby 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 4frame with one tile missing. Let's call the missing tile 'x'; theobject of the puzzle is to arrange the tiles so that they are orderedas:
 1  2  3  4

 5  6  7  8

 9 10 11 12

13 14 15  x


wherethe only legal operation is to exchange 'x' with one of the tiles withwhich it shares an edge. As an example, the following sequence of movessolves 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->


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

Not allpuzzles can be solved; in 1870, a man named Sam Loyd was famous fordistributing an unsolvable version of the puzzle,
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值