题目传送门 本题知识点:深度优先搜索 + 暴力枚举 + 回溯 + 栈 如果对以上知识点还不熟悉的同学建议先做做 POJ1753 (本题是1753的提高版)(附 POJ1753博客) 以下默认您已ACPOJ1753 相信AC了Flip Game 这题的你,一看到这题就很自然地想到套 Filp Game 的模板.没错,其实几乎是一模一样的.只是存储数据有了一些不同而已.熟悉栈的话你也很自然想到用栈啦. 这里也是"翻棋",只不过翻的不只是上下左右了,是要翻一整行列,所以这里要修改一下. 情况…
[题目链接] http://poj.org/problem?id=2965 [算法] 位运算 [代码] #include <algorithm> #include <bitset> #include <cctype> #include <cerrno> #include <clocale> #include <cmath> #include <complex> #include <cstdio> #includ…
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' 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…
2965 he Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 19995   Accepted: 7695   Special Judge Description The game “The Pilots Brothers: following the stripy elephant” has a quest where a player needs to op…
  The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 15176   Accepted: 5672   Special Judge Description The game “The Pilots Brothers: following the stripy elephant” has a quest where a player needs to open…
The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 15136   Accepted: 5660   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: 17450   Accepted: 6600   Special Judge Description The game “The Pilots Brothers: following the stripy elephant” has a quest where a player needs to open a…
[BZOJ2096][Poi2010]Pilots Description Tz又耍畸形了!!他要当飞行员,他拿到了一个飞行员测试难度序列,他设定了一个难度差的最大值,在序列中他想找到一个最长的子串,任意两个难度差不会超过他设定的最大值.耍畸形一个人是不行的,于是他找到了你. Input 输入:第一行两个有空格隔开的整数k(0<=k<=2000,000,000),n(1<=n<=3000,000),k代表Tz设定的最大值,n代表难度序列的长度.第二行为n个由空格隔开的整数ai(1&…
题目链接:http://poj.org/problem?id=2965 The Pilots Brothers' refrigerator Time Limit: 1000MS Memory Limit: 65536K Description The game "The Pilots Brothers: following the stripy elephant" has a quest where a player needs to open a refrigerator. Ther…
The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 27893   Accepted: 10802   Special Judge Description The game “The Pilots Brothers: following the stripy elephant” has a quest where a player needs to open…
题目:http://poj.org/problem?id=2965 来源:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=26732#problem/B 题意: 就是把题目中给出的状态图,全部翻转成 ---- ---- ---- ----状态 翻转: 每次翻转一个,那么它所在的行和列都要翻转 问最小翻转次数,同时输出翻转路径. 算法: 暴力 + 枚举 + dfs 思路: 可以证明每个把手要么翻转,要么不翻转,那么从左到右,从上到下依次枚…
题意 游戏“The Pilots Brothers:跟随有条纹的大象”有一个玩家需要打开冰箱的任务. 冰箱门上有16个把手.每个手柄可以处于以下两种状态之一:打开或关闭.只有当所有把手都打开时,冰箱才会打开.手柄表示为矩阵4х4.您可以在任何位置[i,j](1≤i,j≤4)更改句柄的状态.但是,这也会更改第i行中所有句柄的状态以及第j列中的所有句柄. 任务是确定打开冰箱所需的最小手柄切换次数. 思路 一个和“费解的开关”,"棋盘翻转",这样的位运算的题目很像,只不过这次一次翻转1行+1…
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 states: open or closed. The refrigerator is open o…
  Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20325   Accepted: 7830   Special Judge Description The game “The Pilots Brothers: following the stripy elephant” has a quest where a player needs to open a refrigerator. There are 16 hand…
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 states: open or closed. The refrigerat…
题目链接: http://poj.org/problem?id=1753 题意: 给定冰箱门的开关情况,改变一个门则其所在行列的门都会发生改变,求出改变门的最少操作使得最终所有门都是打开状态. 代码: bfs+状态压缩很容易想到~~ 这里的状态压缩要需要多加小心,注意一下存储的是翻转门的情况~ #include<iostream> #include<cstdio> #include<queue> using namespace std; typedef pair<…
题目链接:http://poj.org/problem?id=2965 题解:自己想到的方法是枚举搜索,结果用bfs和dfs写都超时了.网上拿别人的代码试一下只是刚好不超时的,如果自己的代码在某些方面不够优化,那超时很正常.看来这题用dfs和bfs都不是好办法. 然后又看到比较厉害的技巧:“可知翻偶数次等于没翻,即没有翻的必要,翻奇数次的结果与翻一次的结果一样“”.有了这个重要结论,那么可以具体操作了:设一个二维数组以记录每个的翻转次数.对于每个‘+’,都翻转其所在的行列(注意‘+’只翻一次),…
题目链接:http://poj.org/problem?id=2965 分析:1.这道题和之前做的poj1753题目差不多,常规思路也差不多,但是除了要输出最少步数外,还要输出路径.做这道题的时候在怎么输出bfs的路径上卡了下,然后为了方便输出试用dfs写了下,结果TLE了.T^T(不开森.... 2.还有个地方调bug调了挺久的,bfs里面记录路径的时候要记录当前状态的上一个状态,结果没有判断这个状态是否加入队列过就直接改变了,见代码注释处. 3.重点是会写bfs记录路径了. 4.听说这道题有…
https://vjudge.net/problem/POJ-2965 与poj-1753相似,只不过这个要记录路径.poj-1753:https://www.cnblogs.com/fht-litost/p/9160723.html 题意 4*4的方格,翻转其中的一个把手,会带动同行同列的把手一起动.现要求把所有把手都翻成‘-’状态,问最少需要几步. 分析 异曲同工之妙.加个vector记录路径即可.使用状态压缩的写法输出路径也很方便. #include<iostream> #include…
题目链接 题意:一个冰箱上有4*4共16个开关,改变任意一个开关的状态(即开变成关,关变成开)时,此开关的同一行.同一列所有的开关都会自动改变状态.要想打开冰箱,要所有开关全部打开才行. 输入:一个4×4的矩阵,+表示关闭,-表示打开:输出:使冰箱打开所需要执行的最少操作次数,以及所操作的开关坐标. 题解:核心其实就是,把开关本身以及其同一行同一列的开关(总共7个)都进行一次操作,结果是,开关本身状态改变了7次,开关同一行.同一列的开关状态改变了4次,其他开关状态改变了2次.这就相当于只改变了本…
http://poj.org/problem?id=2965 这个题的话,一开始也不会做,旁边的人说用BFS,后来去网上看了众大神的思路,瞬间觉得用BFS挺简单易:因为要让一个“+”变为“-”,只要将加号所在的位置(i,j)的行和列上的7个元素全部改变一次,这样的话(i,j)这个点将会变化7次,而 i 行上和 j 列另外六个元素将会变化4次,剩下的那些会变化2次,显而易见的是,一个位置上若翻转偶数次相当于没翻转,所以,只要记录下奇数次的翻转进行相加就可以了. #include<cstdio>…
//题目:http://poj.org/problem?id=2965//题意:电冰箱有16个把手,每个把手两种状态(开‘-’或关‘+’),只有在所有把手都打开时,门才开,输入数据是个4*4的矩阵,因此考虑用位表示.可以改变任意一个把手的位置,但同时改变其所在的行和列.求最小步骤.//耗时 800MS1 #include<stdio.h> #include<string.h> #include<stdlib.h> #include<queue> using…
转载请注明出处:http://blog.csdn.net/a1dark 分析:如果想要将一个“+”翻转成“-”,那么必然会把对应的行和列上的所有点翻转一次.由于一个点翻偶数次就相当于不翻转.所以我需要统计“+”.然后将对应行和列的值+1.最后统计奇数值的个数.便是要翻转的点. #include<stdio.h> int mpt[5][5]; int main(){ char ch; for(int i=1;i<=4;i++){ for(int j=1;j<=4;j++){ scan…
http://poj.org/problem?id=2965 题意: 一个4*4的矩形,有'+'和'-'两种符号,每次可以转换一个坐标的符号,同时该列和该行上的其他符号也要随之改变.最少需要几次才能全部变成'-'. 思路: 这道题和黑白棋那道题目差不多,唯一的差别就是需要记录一下路径. 我是用BFS来做的,用二进制来存储.翻转时用位运算的异或比较方便,可以看一下我的这篇博客(http://www.cnblogs.com/zyb993963526/p/6347741.html),上面写的比较清楚.…