1038 Bugs Integrated, Inc.//状态压缩DP-程序员宅基地

技术标签: output  bugs  input  ACM_动态规划  search  integer  each  

 

Bugs Integrated, Inc.
Time Limit: 15000MS   Memory Limit: 30000K
Total Submissions: 5762   Accepted: 2069
Case Time Limit: 5000MS

Description

Bugs Integrated, Inc. is a major manufacturer of advanced memory chips. They are launching production of a new six terabyte Q-RAM chip. Each chip consists of six unit squares arranged in a form of a 2*3 rectangle. The way Q-RAM chips are made is such that one takes a rectangular plate of silicon divided into N*M unit squares. Then all squares are tested carefully and the bad ones are marked with a black marker.

Finally, the plate of silicon is cut into memory chips. Each chip consists of 2*3 (or 3*2) unit squares. Of course, no chip can contain any bad (marked) squares. It might not be possible to cut the plate so that every good unit square is a part of some memory chip. The corporation wants to waste as little good squares as possible. Therefore they would like to know how to cut the plate to make the maximum number of chips possible.
Task
You are given the dimensions of several silicon plates and a list of all bad unit squares for each plate. Your task is to write a program that computes for each plate the maximum number of chips that can be cut out of the plate.

Input

The first line of the input file consists of a single integer D (1 <= D <= 5), denoting the number of silicon plates. D blocks follow, each describing one silicon plate. The first line of each block contains three integers N (1 <= N <= 150), M (1 <= M <= 10), K (0 <= K <= MN) separated by single spaces. N is the length of the plate, M is its height and K is the number of bad squares in the plate. The following K lines contain a list of bad squares. Each line consists of two integers x and y (1 <= x <= N, 1 <= y <= M) ?coordinates of one bad square (the upper left square has coordinates [1, 1], the bottom right is [N,M]).

Output

For each plate in the input file output a single line containing the maximum number of memory chips that can be cut out of the plate.

Sample Input

2
6 6 5
1 4
4 6
2 2
3 6
6 4
6 5 4
3 3
6 1
6 2
6 4

Sample Output

3
4

Source

 

 
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/hqd_acm/article/details/6213511

智能推荐

Linux下解压与压缩命令_linux解压rpm-程序员宅基地

文章浏览阅读4.3k次,点赞4次,收藏34次。本文主要是总结题主在学习与工作中使用到的Linux环境下解压与压缩命令,内容不算很全,但是囊括了大部分需求场景,如有误笔之处,还请同学指正。_linux解压rpm

前端展示后台服务器中图片的功能实现_前端访问后端图片展示-程序员宅基地

文章浏览阅读451次,点赞11次,收藏8次。这里的按钮我是放在了table表格的末尾,目的是获取每一行中的批次号,然后根据批次号读取后台服务器的图片,并且展示在前端的dialog中。有图片的效果图,这里只是做了个测试,图片的大小暂时还未调整。主要是一个接口还有个工具类,代码如下。dialog部分的代码。_前端访问后端图片展示

win10驱动开发——驱动签名_免费驱动签名-程序员宅基地

文章浏览阅读3.4k次,点赞3次,收藏11次。win1803开始直接禁用驱动强制签名的方式不行了1.设置环境bcdedit -set NOINTEGRITYCHECKS ONbcdedit -set TESTSIGNING ONbcdedit -set loadoptions DDISABLE_INTEGRITY_CHECKS2.配置环境变量找到makecert.exe文件位置如【C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x64\makecert.exe】没有的请_免费驱动签名

云计算的三种云部署模型和三种服务模式_基础设施即服务(iaas)从部署的情况来分,可以分为那三种?-程序员宅基地

文章浏览阅读1.1k次。云计算的三种主要服务模式——基础设施即服务(IaaS)、平台即服务(PaaS)和软件即服务(SaaS这三者在存储和资源池方面可以为企业提供的服务存在明显差异,但它们也可以相互交互以形成一个全面的云计算模型。1、基础设施即服务(IaaS)基础设施即服务有时缩写为IaaS,包含云IT的基本构建块,通常提供对联网功能、计算机(虚拟或专用硬件)以及数据存储空间的访问。基础设施即服务提供最高等级的灵活性和对IT资源的管理控制,其机制与现今众多IT部门和开发人员所熟悉的现有。_基础设施即服务(iaas)从部署的情况来分,可以分为那三种?

正点原子的串口助手XCOM V2.0编码问题-程序员宅基地

文章浏览阅读8k次,点赞4次,收藏11次。该串口助手文本和16进制之间的转换是通过GBK2312来实现的,我还一直以为是Unicode方式如下以“博客园”三个汉字为例:_xcom v2.0

最新opencv-c++安装及配置教程(VS2019 C++ & opencv4.4.0)_c++ opencv配置-程序员宅基地

文章浏览阅读5.2w次,点赞104次,收藏458次。以前写过opencv python的安装教程,后来有一些同学开始私信我如何安装及配置opencv c++。本文是以最新的版本入手,一步步详解opencv c++ 的安装及配置过程。:第一步,下载解压opencv 算法库进入到以下链接:https://opencv.org/releases/ , 点击Windows,即可下载。其他系统可忽略本教程。笔者下载的是opencv 4.4.0 ,如果想尝试预发行版,可以选择opencv 4.5.0。下载之后双击,在抽取文件的目录中选择你想要存放的磁盘和文件即_c++ opencv配置

随便推点

【二、大数据环境篇】001、方法论_方法论semma-程序员宅基地

文章浏览阅读405次。1、官网的文档无论是学习Hadoop的hdfs、hive,还是hbase等,都要非常看重官网的文档。大数据的很多框架,都是Apache的顶级项目,各个组件框架的官网链接都可以从下面的链接进入:Hadoop:http://hadoop.apache.org/Avro: 序列化系统HBase: 分布式数据库Hive: 数据仓库Mahout: 机器学习与数据挖掘库Pig: 并行计算的高级数据..._方法论semma

LDA算法的数学推导过程详解-程序员宅基地

文章浏览阅读411次,点赞8次,收藏21次。主题模型是自然语言处理和文本挖掘领域的一个重要研究方向,它可以自动发现文档集合中潜在的主题结构。其中,潜在狄利克雷分配(Latent Dirichlet Allocation, LDA)是最常用和最成功的主题模型之一。LDA是一种无监督的贝叶斯概率模型,能够有效地发现文档集合中隐藏的主题结构。LDA模型的核心思想是:每个文档可以表示为多个主题的概率分布,每个主题又可以表示为词语的概率分布。通过学习这些潜在的主题分布和词语分布,LDA模型可以发现文档集合中蕴含的语义主题信息。

Python利用fitz库提取pdf中的图片(针对多种类型pdf)_import fitz-程序员宅基地

文章浏览阅读2.3w次,点赞17次,收藏98次。目录一. 安装fitz二. pdf文件格式问题2.1 pdf文件存在多种格式2.2 分析问题三. 代码一. 安装fitz安装:需要安装fitz和PyMuPDF,否则会报如下错误:ModuleNotFoundError: No module named ‘frontend’pip install fitz PyMuPDF二. pdf文件格式问题2.1 pdf文件存在多种格式pdf文件的格式有好几种,用Adobe Acrobat比较正常的如下所示:这种类型的pdf文件可以比较正常地提取里面的图片_import fitz

for循环倒序java_for循环-程序员宅基地

文章浏览阅读5.4k次。除了while和do while循环,Java使用最广泛的是for循环。for循环的功能非常强大,它使用计数器实现循环。for循环会先初始化计数器,然后,在每次循环前检测循环条件,在每次循环后更新计数器。计数器变量通常命名为i。我们把1到100求和用for循环改写一下:// for----public class Main {public static void main(String[] arg..._java for 倒序

VS中未定义标识符cout,endl_未定义标识符 "endl-程序员宅基地

文章浏览阅读1w次,点赞6次,收藏10次。VS中未定义标识符vs2017中显示未定义标识符cout,endl。一种方法是:先看有没有包含输入输出流#include,以及命名空间using namespace std;第二种:如果上面都已包含,还是显示未定义标识符的话,检查一下,#include"pch.h"是否是在#include上面我就是犯了第二个错误..._未定义标识符 "endl

python 实现AES-CMAC算法验证_aescmac算法验证-程序员宅基地

文章浏览阅读797次,点赞7次,收藏14次。如果你也是看准了Python,想自学Python,在这里为大家准备了丰厚的免费。_aescmac算法验证

推荐文章

热门文章

相关标签