
状态压缩
coldfresh
那我们开始吧
展开
-
Corn Fields POJ - 3254(状态压缩dp入门)
Farmer John has purchased a lush new rectangular pasture composed of M by N (1 ≤ M ≤ 12; 1 ≤ N ≤ 12) square parcels. He wants to grow some yummy corn for the cows on a number of squares. Regrettably, s原创 2017-07-06 12:37:51 · 862 阅读 · 0 评论 -
青蛙跳杯子(bfs+状态压缩)
题目描述 X星球的流行宠物是青蛙,一般有两种颜色:白色和黑色。 X星球的居民喜欢把它们放在一排茶杯里,这样可以观察它们跳来跳去。 如下图,有一排杯子,左边的一个是空着的,右边的杯子,每个里边有一只青蛙。*WWWBBB其中,W字母表示白色青蛙,B表示黑色青蛙,*表示空杯子。X星的青蛙很有些癖好,它们只做3个动作之一: 1. 跳到相邻的空杯子里。 2. 隔着1只其它的青蛙(随...原创 2019-02-27 15:04:27 · 314 阅读 · 0 评论 -
【51nod】环
基准时间限制:1 秒 空间限制:131072 KB 分值: 80 有一个有向图。这张图有n个点和m条有向边。 他很好奇不相交的环(简单环)来覆盖所有点的方案数(数字可能很大请模998,244,353)。 Input 第一行有n和m。(1<=n<=20,1<=m<=n*(n-1)) 后面m行描述着m条边。 输入保证没有重边自环。 Output 输出方案数。 ...原创 2018-09-03 19:44:23 · 268 阅读 · 0 评论 -
Maze HDU - 5094(BFS)
This story happened on the background of Star Trek. Spock, the deputy captain of Starship Enterprise, fell into Klingon’s trick and was held as prisoner on their mother planet Qo’noS. The captain ...原创 2018-07-16 21:24:46 · 248 阅读 · 0 评论 -
Problem Arrangement ZOJ - 3777 (状压dp)
The 11th Zhejiang Provincial Collegiate Programming Contest is coming! As a problem setter, Edward is going to arrange the order of the problems. As we know, the arrangement will have a great effect o...原创 2018-04-25 18:43:44 · 229 阅读 · 0 评论 -
Islands and Bridges POJ - 2288
题目链接:http://poj.org/problem?id=2288题意:仍然是求一条哈密顿回路,不过权值和的计算包括三部分:所经过的点权和,连续经过的两个点的权值乘积,连续三个点彼此可达则再加上三点乘积,问最大权值为多少,且有多少种方案达到该权值,注意一条路径的走法只能算一次评价:这题我一看就知道是状压dp,一般我能一眼看出来思路的都是水题,但是实现上出了很多问题,原来这题是会超int...原创 2018-03-03 19:39:07 · 243 阅读 · 0 评论 -
Travel HDU - 4284(dfs或状压dp)
PP loves travel. Her dream is to travel around country A which consists of N cities and M roads connecting them. PP has measured the money each road costs. But she still has one more problem: she doesn原创 2017-11-05 20:45:01 · 346 阅读 · 0 评论 -
Maximum Subsequence CodeForces - 888E (二分+状压)
You are given an array a consisting of n integers, and additionally an integer m. You have to choose some sequence of indices b1, b2, …, bk (1 ≤ b1 < b2 < … < bk ≤ n) in such a way that the value of i原创 2017-11-12 16:51:12 · 930 阅读 · 0 评论 -
方格取数(1) HDU - 1565(状压dp)
给你一个n*n的格子的棋盘,每个格子里面有一个非负数。 从中取出若干个数,使得任意的两个数所在的格子没有公共边,就是说所取的数所在的2个格子不能相邻,并且取出的数的和最大。 Input 包括多个测试实例,每个测试实例包括一个整数n 和n*n个非负数(n<=20) Output 对于每个测试实例,输出可能取得的最大的和 Sample Input 3 75 15 21 75 15原创 2017-11-08 21:47:36 · 394 阅读 · 0 评论 -
Mondriaan's Dream POJ - 2411(插头做法带更新)
Squares and rectangles fascinated the famous Dutch painter Piet Mondriaan. One night, after producing the drawings in his ‘toilet series’ (where he had to use his toilet paper to draw on, for all of hi原创 2017-07-17 21:47:49 · 308 阅读 · 0 评论 -
Most Powerful ZOJ - 3471
Recently, researchers on Mars have discovered N powerful atoms. All of them are different. These atoms have some properties. When two of these atoms collide, one of them disappears and a lot of power i原创 2017-07-17 17:21:14 · 328 阅读 · 0 评论 -
Travelling HDU - 3001
After coding so many days,Mr Acmer wants to have a good rest.So travelling is the best choice!He has decided to visit n cities(he insists on seeing all the cities!And he does not mind which city being原创 2017-07-17 14:34:13 · 408 阅读 · 0 评论 -
Hie with the Pie POJ - 3311(wa)
The Pizazz Pizzeria prides itself in delivering pizzas to its customers as fast as possible. Unfortunately, due to cutbacks, they can afford to hire only one driver to do the deliveries. He will wait f原创 2017-07-17 10:49:52 · 315 阅读 · 0 评论 -
炮兵阵地 POJ - 1185(状态压缩)
司令部的将军们打算在N*M的网格地图上部署他们的炮兵部队。一个N*M的地图由N行M列组成,地图的每一格可能是山地(用”H” 表示),也可能是平原(用”P”表示),如下图。在每一格平原地形上最多可以布置一支炮兵部队(山地上不能够部署炮兵部队);一支炮兵部队在地图上的攻击范围如图中黑色区域所示: 如果在地图中的灰色所标识的平原上部署一支炮兵部队,则图中的黑色的网格表示它能够攻击到的区域:沿横向左右各两格原创 2017-07-16 15:25:06 · 503 阅读 · 0 评论 -
【tyvj-1266】费解的开关(状压枚举)
题目链接题目大意:给一个5*5的的灯泡,0代表暗,1代表亮,有一个操作,多一个灯泡操作,使得本身和上下左右的的灯泡的状态相反,问能否在6步之内,使得所有的灯泡的都变亮,求最小的操作的步数,如果无解或者步数大于6则输出-1**思路:**枚举第一排的操作数,那么接下来的2到5排的操作实际上都是确定的,那么就二进制的去枚举第一排的情况,一共是32种。代码:#include<iostream...原创 2019-03-01 13:50:43 · 368 阅读 · 0 评论