题目链接:http://poj.org/problem?id=2965 题解:自己想到的方法是枚举搜索,结果用bfs和dfs写都超时了.网上拿别人的代码试一下只是刚好不超时的,如果自己的代码在某些方面不够优化,那超时很正常.看来这题用dfs和bfs都不是好办法. 然后又看到比较厉害的技巧:“可知翻偶数次等于没翻,即没有翻的必要,翻奇数次的结果与翻一次的结果一样“”.有了这个重要结论,那么可以具体操作了:设一个二维数组以记录每个的翻转次数.对于每个‘+’,都翻转其所在的行列(注意‘+’只翻一次),…
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…
题目链接:http://poj.org/problem?id=2965 分析:1.这道题和之前做的poj1753题目差不多,常规思路也差不多,但是除了要输出最少步数外,还要输出路径.做这道题的时候在怎么输出bfs的路径上卡了下,然后为了方便输出试用dfs写了下,结果TLE了.T^T(不开森.... 2.还有个地方调bug调了挺久的,bfs里面记录路径的时候要记录当前状态的上一个状态,结果没有判断这个状态是否加入队列过就直接改变了,见代码注释处. 3.重点是会写bfs记录路径了. 4.听说这道题有…
The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 16868   Accepted: 6393   Special Judge Description The game “The Pilots Brothers: following the stripy elephant” has a quest where a player needs to open a…
The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22286   Accepted: 8603   Special Judge Description The game “The Pilots Brothers: following the stripy elephant” has a quest where a player needs to open a…
The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22057   Accepted: 8521   Special Judge Description The game “The Pilots Brothers: following the stripy elephant” has a quest where a player needs to open a…
The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 19718   Accepted: 7583   Special Judge Description The game “The Pilots Brothers: following the stripy elephant” has a quest where a player needs to open a…
题目地址:http://poj.org/problem?id=2965 /* 题意:4*4的矩形,改变任意点,把所有'+'变成'-',,每一次同行同列的都会反转,求最小步数,并打印方案 DFS:把'+'记为1, '-'记为0 1. 从(1, 1)走到(4, 4),每一点DFS两次(改点反转或不反转):used记录反转的位置 详细解释:http://poj.org/showmessage?message_id=346723 2. 比较巧妙的解法:抓住'+'位置反转,'-'位置相对不反转的特点,从状…
The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20304   Accepted: 7823   Special Judge Description The game "The Pilots Brothers: following the stripy elephant" has a quest where a player needs to o…