博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Beta Round #85 (Div. 1 Only) C (状态压缩或是数学?)
阅读量:4650 次
发布时间:2019-06-09

本文共 1343 字,大约阅读时间需要 4 分钟。

C. Petya and Spiders

Little Petya loves training spiders. Petya has a board n × m in size. Each cell of the board initially has a spider sitting on it. After one second Petya chooses a certain action for each spider, and all of them humbly perform its commands. There are 5 possible commands: to stay idle or to move from current cell to some of the four side-neighboring cells (that is, one command for each of the four possible directions). Petya gives the commands so that no spider leaves the field. It is allowed for spiders to pass through each other when they crawl towards each other in opposite directions. All spiders crawl simultaneously and several spiders may end up in one cell. Petya wants to know the maximum possible number of spider-free cells after one second.

Input

The first line contains two space-separated integers n and m (1 ≤ n, m ≤ 40, n·m ≤ 40) — the board sizes.

Output

In the first line print the maximum number of cells without spiders.

Sample test(s)
input
1 1
output
0
input
2 3
output
4

 

题意:开始得分时候每个格子都有蜘蛛,然后每一秒钟蜘蛛可以向四个方向爬行,或者静止不动。 问1秒后有多少格子时空的。

sl : 貌似很久以前就看过这个题目但是因为种种原因不会搞,看题解也不明白,今天徒手花了下,感觉能搞,但是最后还是wa了,实在是逗。

看了题解,果然是经典的状压啊。 dp[i][now][pre] 表示 第i行蜘蛛的状态为now 上一行的状态为 pre,  这时候可能会出现不合法的转移。怎么不合法呢

就是相邻的两行的蜘蛛加上当前的蜘蛛数目不等于全部蜘蛛的数目,然后转移就好办了。从上一行转移过来,记录下上一行出现了多少个蜘蛛就好了。

 

 

 

转载于:https://www.cnblogs.com/acvc/p/3917145.html

你可能感兴趣的文章
强名称程序集(strong name assembly)——为程序集赋予强名称
查看>>
1028. List Sorting (25)
查看>>
BZOJ 1613: [Usaco2007 Jan]Running贝茜的晨练计划
查看>>
ubuntu 重启命令,ubuntu 重启网卡方法
查看>>
Linux的学习:
查看>>
JavaScript中的原型继承原理
查看>>
Python logger模块
查看>>
jquery控制css的display(控制元素的显示与隐藏)
查看>>
关于python做人工智能的一个网页(很牛逼)
查看>>
判断控件的CGRect是否重合,获取控件的最大XY值
查看>>
POJ-1128 Frame Stacking
查看>>
浏览器调试淘宝首页看到有趣的招聘信息
查看>>
ASP.NET Identity “角色-权限”管理 4
查看>>
[转][译]ASP.NET MVC 4 移动特性
查看>>
SurfaceView+MediaPlay的bug们
查看>>
网络表示学习总结
查看>>
完成评论功能
查看>>
far和near
查看>>
Python爬虫实战四之抓取淘宝MM照片
查看>>
2015 Multi-University Training Contest 1
查看>>