Tiling Up Blocks_DP
Description

Each tiling block is associated with two parameters (l,m), meaning that the upper face of the block is packed with l protruding knobs on the left and m protruding knobs on the middle. Correspondingly, the bottom face of an (l,m)-block is carved with l caving dens on the left and m dens on the middle.
It is easily seen that an (l,m)-block can be tiled upon another (l,m)-block. However,this is not the only way for us to tile up the blocks. Actually, an (l,m)-block can be tiled upon another (l',m')-block if and only if l >= l' and m >= m'.
Now the puzzle that Michael wants to solve is to decide what is the tallest tiling blocks he can make out of the given n blocks within his game box. In other words, you are given a collection of n blocks B = {b1, b2, . . . , bn} and each block bi is associated with two parameters (li,mi). The objective of the problem is to decide the number of tallest tiling blocks made from B.
Input
Note that n can be as large as 10000 and li and mi are in the range from 1 to 100.
An integer n = 0 (zero) signifies the end of input.
Output
outputs.
Sample Input
3
3 2
1 1
2 3
5
4 2
2 4
3 3
1 1
5 5
0
Sample Output
2
3
*
【题意】给出n块积木的左右凹凸的数量,问最高能搭多高;
【思路】dp[i][j]=max(dp[i][j-1],dp[i-1][j])+cnt[i][j];
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
const int N=;
int dp[N][N];
int cnt[N][N]; int main()
{
int n;
while(~scanf("%d",&n),n)
{
memset(dp,,sizeof(dp));
memset(cnt,,sizeof(cnt));
for(int i=;i<n;i++)
{
int x,y;
scanf("%d%d",&x,&y);
cnt[x][y]++;
}
for(int i=;i<=;i++)
{
for(int j=;j<=;j++)
{
dp[i][j]=max(dp[i-][j],dp[i][j-])+cnt[i][j];
}
}
printf("%d\n",dp[][]);
}
printf("*\n");
return ;
}
Tiling Up Blocks_DP的更多相关文章
- Texture tiling and swizzling
Texture tiling and swizzling 原帖地址:http://fgiesen.wordpress.com If you’re working with images in your ...
- 图文详解Unity3D中Material的Tiling和Offset是怎么回事
图文详解Unity3D中Material的Tiling和Offset是怎么回事 Tiling和Offset概述 Tiling表示UV坐标的缩放倍数,Offset表示UV坐标的起始位置. 这样说当然是隔 ...
- POJ3420Quad Tiling(矩阵快速幂)
Quad Tiling Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3740 Accepted: 1684 Descripti ...
- Tri Tiling[HDU1143]
Tri Tiling Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total ...
- Tiling 分类: POJ 2015-06-17 15:15 8人阅读 评论(0) 收藏
Tiling Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8091 Accepted: 3918 Descriptio ...
- I - Tri Tiling
Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Status #in ...
- POJ2506——Tiling
Tiling Description In how many ways can you tile a 2xn rectangle by 2x1 or 2x2 tiles? Here is a samp ...
- [POJ 3420] Quad Tiling
Quad Tiling Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3495 Accepted: 1539 Des ...
- uva 11270 - Tiling Dominoes(插头dp)
题目链接:uva 11270 - Tiling Dominoes 题目大意:用1∗2木块将给出的n∗m大小的矩阵填满的方法总数. 解题思路:插头dp的裸题,dp[i][s]表示第i块位置.而且该位置相 ...
随机推荐
- tableview调用reloadData()之后界面不刷新显示
解决方法: 查看是否有指定tableView的delegate和datasource. self.tableView.delegate = self self.tableView.datasource ...
- Oracle知识整理
1.自带三种登录方式: Scott/tiger sys/manager system/manager 2.基本的操作 1) 建数据库 create tablespace 表空间的名称 dat ...
- c# form的设定
1. 窗体的显示位置startPosition CenterScreen 窗体在当前居中 CenterParent 窗体在其父窗体居中 WindowDefaultBounds 窗体定期在windows ...
- 449. Serialize and Deserialize BST——几乎所有树的面试题目都会回到BFS或者DFS,使用BFS,None节点存#
Serialization is the process of converting a data structure or object into a sequence of bits so tha ...
- R中rJava包载入时报错的问题
今天安装XLConnect包,安装后无法library(XLConnect)载入,看报错问题应该出在rJava上,找到了下面的解决办法: if (Sys.getenv("JAVA_HOME& ...
- shell学习记录003-cat命令
cat 命令一般用于文件的查看 cat -s file #可以去除文件中多余的上下空行 cat -T file #Python编程中会用到的制表符会在该命令中体现出来 cat -n file ...
- thinking in java 之Reference类的使用
Reference是java中的特殊引用类.描述的是特殊作用(主要是关于垃圾回收对象)的引用. 它有3个子类: 1.SoftReference; 2.WeakReference 3.PhantomRe ...
- [转] jQuery源码分析-如何做jQuery源码分析
jQuery源码分析系列(持续更新) jQuery的源码有些晦涩难懂,本文分享一些我看源码的方法,每一个模块我基本按照这样的顺序去学习. 当我读到难度的书或者源码时,会和<如何阅读一本书> ...
- android 计算器的实现(转)
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...
- 从QQ网站中提取的纯JS省市区三级联动
在 http://ip.qq.com/ 的网站中有QQ自己的JS省市区三级联动 QQ是使用引用外部JS来实现三级联动的.JS如下:http://ip.qq.com/js/geo.js <!DOC ...