POJ 3221 Diamond Puzzle(BFS)
Description A diamond puzzle is played on a tessellated hexagon like the one shown in Figure 1 below. And in this problem the faces produced by the tessellation are identified as they are numbered in the same figure. If two faces share a side, they ![]() Starting from any configuration, some series of moves can always make the puzzle look identical to either one shown in Figures 2 and 3. Your task is to calculate the minimum number of moves to make it become the one inFigure Input The input contains multiple test cases. The first contains an integer N (0 ≤ N ≤ 5,040), the number of test cases. Then follow N lines, each with a permutation of {0, 1, 2, 3, 4, 5, 6} describing a starting configuration of the Output For each test cases, output the minimum number of moves the configuration takes to reach the one shown in Figure 2. If this is impossible, just output “ Sample Input 3 Sample Output 10 渣渣水平看了题解,果断bfs走起。 ps:博客写的太简单了,由于时间比較紧。所以以后时间充足的话还是具体点好。 题意:由当前状态得到终于状态须要最小步数。仅仅同意在空格处移动=-=。从终于状态開始搜 所以就记录0所在位子以及由此0能够移动到的位置。 比方:0在位置2,则3,0,1号位置都能够移动到此位置。 另外的对于我来说就是STL里map的使用了,映射关系map<string,int>visit记录有木有被訪问过,map<string,int>ans记录到谋一状态所需的最小步数。 以下贴挫码。 思路来源:点击打开链接 #include<iostream> |
POJ 3221 Diamond Puzzle(BFS)的更多相关文章
- POJ 3984 迷宫问题(BFS)
迷宫问题 Description 定义一个二维数组: int maze[5][5] = { 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, ...
- POJ 2435Navigating the City(bfs)
题意:给你一个地图,’+’代表十字路口,‘-’‘|’表示街道,‘.’表示建筑物,‘s’,’E’ 起点和终点.输出从起点到终点的的 最短路径(包括方向和沿该方向的经过的十字路口数) 分析:ans[i][ ...
- poj 3669 Meteor Shower(bfs)
Description Bessie hears that an extraordinary meteor shower is coming; reports say that these meteo ...
- POJ 3221 Diamond Puzzle.
~~~~ 题目链接:http://poj.org/problem? id=3221 显然是BFS找最优解.但是终止条件不好写.看到有一仅仅队交上去一直TLE. 比赛完了看题解原来是以目标状态为起点,B ...
- 【POJ - 3414】Pots(bfs)
Pots 直接上中文 Descriptions: 给你两个容器,分别能装下A升水和B升水,并且可以进行以下操作 FILL(i) 将第i个容器从水龙头里装满(1 ≤ i ≤ 2); DRO ...
- POJ 1573 Robot Motion(BFS)
Robot Motion Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 12856 Accepted: 6240 Des ...
- POJ 3126 Prime Path (BFS)
[题目链接]click here~~ [题目大意]给你n,m各自是素数,求由n到m变化的步骤数,规定每一步仅仅能改变个十百千一位的数,且变化得到的每个数也为素数 [解题思路]和poj 3278类似.b ...
- poj 2251 Dungeon Master(bfs)
Description You are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is co ...
- POJ 3678 Katu Puzzle (2-SAT)
Katu Puzzle Time Limit: 1000MS ...
随机推荐
- REST SOAP XML-RPC分析比较
本文的标题“REST与SOAP之比较”确实有些让人误解.REST是代表性状态传输的名称首字母缩写,与其说它是标准,不如说是一种风格.然而,在我的前一篇文章中,正如我们所讨论的,众多从事Web服务的软件 ...
- [Atcoder Regular Contest 064] Tutorial
Link: ARC064 传送门 C: 贪心+对边界的特殊处理 #include <bits/stdc++.h> using namespace std; typedef long lon ...
- Scala实战高手****第3课:在IDE下开发第一个Scala程序纯傻瓜式彻底透彻解析
- Using Dtrace OEL 6.X and Oracle® Solaris 11.3 DTrace (Dynamic Tracing) Guide
http://www.hhutzler.de/blog/using-dtrace/ https://docs.oracle.com/cd/E53394_01/html/E53395/gkyaz.htm ...
- JS面向对象函数的四种调用模式
函数的四种调用模式 概念 在 js 中,无论是函数, 还是方法, 还是事件, 还是构造器,...这些东西的本质都是函数 函数, 方法, 事件, 构造器,...只是所处的位置不同 这四种模式分别是 函数 ...
- zk client获取数据
获取数据 它返回znode的关联数据和指定znode的元数据.你将获得信息,例如上次修改数据的时间,修改的位置以及数据的相关信息.此CLI还用于分配监视器以显示数据相关的通知. 语法 get /pat ...
- 怎么在VS2010中打开VS2013的项目
其实VS2010与VS2013上的sln文件没有本质的区别.打不开的原因是什么呢?其实原因很简单,两者开头的软件信息不同.因此造成低版本VS的不识别. VS2013版本vs.sln文件开头的软件信息: ...
- 折腾kubernetes各种问题汇总
折腾fluend-elasticsearch日志,折腾出一大堆问题,解决这些问题过程中,感觉又了解了不少. 1.如何删除不一致状态下的rc,deployment,service. 在某些情况下,经常发 ...
- ZOJ 3792 Romantic Value 最小割(最小费用下最小边数)
求最小割及最小花费 把边权c = c*10000+1 然后跑一个最小割,则flow / 10000就是费用 flow%10000就是边数. 且是边数最少的情况.. #include<stdio. ...
- linux下GPRS模块的应用程序
---------------------------------------------------------------------------------------------------- ...