转载请注明出处:http://blog.csdn.net/u012860063? viewmode=contents 题目链接:http://poj.org/problem? id=2965 ----------------------------------------------------------------------------------------------------------------------------------------------------------…
The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 19356   Accepted: 7412   Special Judge Description The game "The Pilots Brothers: following the stripy elephant" has a quest where a player needs to o…
id=2965">The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 18080   Accepted: 6855   Special Judge Description The game "The Pilots Brothers: following the stripy elephant" has a quest where a…
The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 18040   Accepted: 6841   Special Judge Description The game "The Pilots Brothers: following the stripy elephant" has a quest where a player needs to o…
链接:poj 2965 题意:给定一个4*4矩阵状态,代表门的16个把手.'+'代表关,'-'代表开.当16个把手都为开(即'-')时.门才干打开,问至少要几步门才干打开 改变状态规则:选定16个把手中的随意一个,能够改变其本身以及同行同列的状态(即若为开,则变为关,若为关,则变为开),这一次操作为一步. 分析:这题与poj 1753思路差点儿相同,每一个把手最多改变一次状态, 全部整个矩阵最多改变16次状态 思路:直接dfs枚举全部状态,直到找到目标状态 可是要打印路径,全部应在dfs时记录路…
The Pilots Brothers' refrigerator Description The game “The Pilots Brothers: following the stripy elephant” has a quest where a player needs to open a refrigerator. There are 16 handles on the refrigerator door. Every handle can be in one of two stat…
题意 游戏“The Pilots Brothers:跟随有条纹的大象”有一个玩家需要打开冰箱的任务. 冰箱门上有16个把手.每个手柄可以处于以下两种状态之一:打开或关闭.只有当所有把手都打开时,冰箱才会打开.手柄表示为矩阵4х4.您可以在任何位置[i,j](1≤i,j≤4)更改句柄的状态.但是,这也会更改第i行中所有句柄的状态以及第j列中的所有句柄. 任务是确定打开冰箱所需的最小手柄切换次数. 思路 一个和“费解的开关”,"棋盘翻转",这样的位运算的题目很像,只不过这次一次翻转1行+1…
I - The Pilots Brothers' refrigerator Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Description The game "The Pilots Brothers: following the stripy elephant" has a quest where a player needs to op…
题目链接:http://poj.org/problem?id=2965 分析:1.这道题和之前做的poj1753题目差不多,常规思路也差不多,但是除了要输出最少步数外,还要输出路径.做这道题的时候在怎么输出bfs的路径上卡了下,然后为了方便输出试用dfs写了下,结果TLE了.T^T(不开森.... 2.还有个地方调bug调了挺久的,bfs里面记录路径的时候要记录当前状态的上一个状态,结果没有判断这个状态是否加入队列过就直接改变了,见代码注释处. 3.重点是会写bfs记录路径了. 4.听说这道题有…
题目链接:http://poj.org/problem?id=2965 题解:自己想到的方法是枚举搜索,结果用bfs和dfs写都超时了.网上拿别人的代码试一下只是刚好不超时的,如果自己的代码在某些方面不够优化,那超时很正常.看来这题用dfs和bfs都不是好办法. 然后又看到比较厉害的技巧:“可知翻偶数次等于没翻,即没有翻的必要,翻奇数次的结果与翻一次的结果一样“”.有了这个重要结论,那么可以具体操作了:设一个二维数组以记录每个的翻转次数.对于每个‘+’,都翻转其所在的行列(注意‘+’只翻一次),…