HDU 4012 Paint on a Wall(状压+bfs)】的更多相关文章

Paint on a Wall Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others)Total Submission(s): 830    Accepted Submission(s): 325 Problem Description Annie wants to paint her wall to an expected pattern. The wall can be repr…
1.状压bfs 这个状压体现在key上  我i们用把key状压一下  就能记录到一个点时 已经拥有的key的种类 ban[x1][y1][x2][y1]记录两个点之间的状态 是门 还是墙 还是啥都没有 inc[x][y]记录这个点所存储的钥匙  (可能不止一个 所以要用二进制) vis[x][y][key]  标记当前点 在拥有的钥匙种类为key时是否走过 #include <iostream> #include <cstdio> #include <sstream>…
状压BFS 注意在用二维字符数组时,要把空格.换行处理好. #include<stdio.h> #include<algorithm> #include<string.h> #include<queue> using namespace std; #define INF 0x3f3f3f3f int sx,sy,C,n,m; int ans; ][][<<]; ][]; ][]; ,,-,},dy[]={,,,-}; <=a&&am…
POJ 1324 Holedox Moving (状压BFS) Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 18091 Accepted: 4267 Description During winter, the most hungry and severe time, Holedox sleeps in its lair. When spring comes, Holedox wakes up, moves to the…
P2622 关灯问题II 题目描述 现有n盏灯,以及m个按钮.每个按钮可以同时控制这n盏灯——按下了第i个按钮,对于所有的灯都有一个效果.按下i按钮对于第j盏灯,是下面3中效果之一:如果a[i][j]为1,那么当这盏灯开了的时候,把它关上,否则不管:如果为-1的话,如果这盏灯是关的,那么把它打开,否则也不管:如果是0,无论这灯是否开,都不管. 现在这些灯都是开的,给出所有开关对所有灯的控制效果,求问最少要按几下按钮才能全部关掉. 输入输出格式 输入格式: 前两行两个数,n m 接下来m行,每行n…
​题意:1个机器人找几个垃圾,求出最短路径. 状压BFS,这道题不能用普通BFS二维vis标记数组去标记走过的路径,因为这题是可以往回走的,而且你也不能只记录垃圾的数量就可以了,因为它有可能重复走同一个垃圾.其实解决的办法就是把vis标记数组开到3维,用来存每次走的状态.再通过位运算即可. 下面是2中常见的位运算操作: 1.加入某一个垃圾:rubblish | =( 1 << i ); eg: 0001 | 0100 =0101 ; 2.进行垃圾匹配 :if( (  rubblish &…
http://acm.hdu.edu.cn/showproblem.php?pid=5094 给出n*m矩阵 给出k个障碍,两坐标之间存在墙或门,门最多10种,状压可搞 给出s个钥匙位置及编号,相应的钥匙开相应的门,求从1,1到n,m的最短时间,不能到底则输出-1 这里有一个大坑:有可能同一个位置有多个门或者多个钥匙... 这么坑大丈夫? #include <cstdio> #include <cstdlib> #include <cmath> #include <…
题目地址:pid=5067">HDU 5067 经典的TSP旅行商问题模型. 状压DP. 先分别预处理出来每两个石子堆的距离.然后将题目转化成10个城市每一个城市至少经过一次的最短时间模型.然后简单的状压DP就可以. 代码例如以下: #include <iostream> #include <cstdio> #include <string> #include <cstring> #include <stdlib.h> #incl…
题目链接:https://cn.vjudge.net/problem/HDU-1565 Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Problem Description 给你一个n*n的格子的棋盘,每个格子里面有一个非负数.从中取出若干个数,使得任意的两个数所在的格子没有公共边,就是说所取的数所在的2个格子不能相邻,并且取出的数的和最大.   Input 包括多个测试实例,每…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4026 Unlock the Cell Phone Time Limit: 6000/3000 MS (Java/Others)Memory Limit: 65768/65768 K (Java/Others) 问题描述 Modern high-tech cell phones use unlock patterns to unlock the system. The pattern is usua…