poj 2836 Rectangular Covering(状态压缩dp)
Description n points are given on the Cartesian plane. Now you have to use some rectangles whose sides are parallel to the axes to cover them. Every point must be covered. And a point can be covered by several rectangles. Each rectangle should cover at least two points including those that fall on its border. Rectangles should have integral dimensions. Degenerate cases (rectangles with zero area) are not allowed. How will you choose the rectangles so as to minimize the total area of them? Input The input consists of several test cases. Each test cases begins with a line containing a single integer n ( ≤ n ≤ ). Each of the next n lines contains two integers x, y (−, ≤ x, y ≤ ,) giving the coordinates of a point. It is assumed that no two points are the same as each other. A single zero follows the last test case. Output Output the minimum total area of rectangles on a separate line for each test case. Sample Input Sample Output Hint The total area is calculated by adding up the areas of rectangles used. Source PKU Local 2006, kicc
先预处理数据,将n个点两两组合形成n * (n-1) / 2个矩形,计算每个矩形的面积和内部点个数。 接着利用预处理数据来枚举,定义 dp[S] := 矩形集为S时的最省面积 先假设平面上没有矩形,那么dp[0]=0,接着一个一个地往平面上加矩形,递推关系是: dp[新矩形集合] = min(dp[新矩形集合], dp[旧矩形集合] + 新矩形的面积); #include<iostream> |
poj 2836 Rectangular Covering(状态压缩dp)的更多相关文章
- POJ 2836 Rectangular Covering (状压DP)
题意:平面上有 n (2 ≤ n ≤ 15) 个点,现用平行于坐标轴的矩形去覆盖所有点,每个矩形至少盖两个点,矩形面积不可为0,求这些矩形的最小面积. 析:先预处理所有的矩形,然后dp[s] 表示 状 ...
- POJ 3254 Corn Fields(状态压缩DP)
Corn Fields Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 4739 Accepted: 2506 Descr ...
- POJ 3691 (AC自动机+状态压缩DP)
题目链接: http://poj.org/problem?id=3691 题目大意:给定N个致病DNA片段以及一个最终DNA片段.问最终DNA片段最少修改多少个字符,使得不包含任一致病DNA. 解题 ...
- POJ 1321 棋盘问题(状态压缩DP)
不总结的话, 同一个地方会 WA 到死 思路: 状态压缩 DP. 1. s 表示压缩状态, 若第 i 列放了棋子, 那么该列置 1, 否则该列置 0. 假如 s = 3(0x011) 那么表示棋盘的第 ...
- POJ 3254 Corn Fields (状态压缩DP)
题意:在由方格组成的矩形里面种草,相邻方格不能都种草,有障碍的地方不能种草,问有多少种种草方案(不种也算一种方案). 分析:方格边长范围只有12,用状态压缩dp好解决. 预处理:每一行的障碍用一个状态 ...
- POJ 3254. Corn Fields 状态压缩DP (入门级)
Corn Fields Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 9806 Accepted: 5185 Descr ...
- poj 2836 Rectangular Covering
Rectangular Covering Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2776 Accepted: 7 ...
- POJ 3254 Corn Fields 状态压缩DP (C++/Java)
id=3254">http://poj.org/problem? id=3254 题目大意: 一个农民有n行m列的地方,每一个格子用1代表能够种草地,而0不能够.放牛仅仅能在有草地的. ...
- POJ 3254 Corn Fields状态压缩DP
下面有别人的题解报告,并且不止这一个状态压缩题的哦···· http://blog.csdn.net/accry/article/details/6607703 下面是我的代码,代码很挫,绝对有很大的 ...
随机推荐
- apache archiva安装教程
1. 下载archiva standalone http://archiva.apache.org/download.cgi 2. 解压,设置ARCHIVA_HOME 环境变量 3.为了防止冲突, ...
- 实现Android 动态载入APK(Fragment or Activity实现)
尊重原创:http://blog.csdn.net/yuanzeyao/article/details/38565345 近期由于项目太大了.导致编译通只是(Android对一个应用中的方法个数貌似有 ...
- 基于bootstrap的datatable控件
https://editor.datatables.net/release/DataTables/extras/Editor/examples/bootstrap.htmlhttps://github ...
- C#,.net获取字符串中指定字符串的个数、所在位置与替换字符串
方法一: public static int indexOf (字符串/字符,int从第几位开始,int共查几位) string tests = "1absjjkcbfka2rsbcfak2 ...
- Java线程同步与死锁认识
讲下自己的认识,算小小的总结吧! synchroized 具有同步线程的功能,它的处理机制类似于给参数里面的对象赋一个标记值,来表明当前状态,当程序里面某个线程执行synchroized里面的代码段时 ...
- 最新版 CocoaPods 的安装流程(包括EI Capitan版)
1.移除现有Ruby默认源 $gem sources --remove https://rubygems.org/ 2.使用新的源 $gem sources -a https://ruby.taoba ...
- effective_c++条款20,用pass-by-reference-to-const替换pass-by-value
pass-by-value void f(A a); 1)导致复制是浪费资源 2)多态是导致对象切割 所以我们使用 void f(const A& a) 上面的话针对class,不针对基本类型 ...
- 1.1C++入门 未完待续。。。
第一个C++程序: #include<iostream> int main() { std::cout << "Hello World !" << ...
- sql server在使用xp_cmdshell
一.sql server在使用xp_cmdshell读取远程服务器上的文件时,要先将远程服务器的目录映射到本地 代码: exec master..xp_cmdshell 'net use P: \\ ...
- js判断一个变量是否为数组的解决方案
前端开发中,在做项目的时候,我们经常需要对一个变量进行数组类型的判断,当然即使你暂时没遇到,但是这个问题也是大家去面试时的高频问题,有必要拿出来说一说. 大家都知道js中可以使用typeof来判断变量 ...