Tiling Up Blocks
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 4675   Accepted: 1824

Description

Michael The Kid receives an interesting game set from his grandparent as his birthday gift. Inside the game set box, there are n tiling blocks and each block has a form as follows: 

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

Several sets of tiling blocks. The inputs are just a list of integers.For each set of tiling blocks, the first integer n represents the number of blocks within the game box. Following n, there will be n lines specifying parameters of blocks in B; each line contains exactly two integers, representing left and middle parameters of the i-th block, namely, li and mi. In other words, a game box is just a collection of n blocks B = {b1, b2, . . . , bn} and each block bi is associated with two parameters (li,mi). 
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

For each set of tiling blocks B, output the number of the tallest tiling blocks can be made out of B. Output a single star '*' to signify the end of 
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个砖块的长和宽,只有当x2>=x1&&y2>=y1时 n2可以放在n1上 问最高能落多高。
解题方法:求最大不上升子序列,用动态规划。
#include <stdio.h>
#include <iostream>
#include <string.h>
using namespace std; int main()
{
int w[][];
int dp[][];
int n;
while(scanf("%d", &n) != EOF)
{
if (n == )
{
printf("*\n");
break;
}
int a, b;
memset(w, , sizeof(w));
memset(dp, , sizeof(dp));
for (int i = ; i <= n; i++)
{
scanf("%d%d", &a, &b);
w[a][b]++;
}
for (int i = ; i <= ; i++)
{
for (int j = ; j <= ; j++)
{
dp[i][j] = max(dp[i - ][j], dp[i][j - ]) + w[i][j];
}
}
printf("%d\n", dp[][]);
}
return ;
}
 

POJ 1609 Tiling Up Blocks的更多相关文章

  1. poj 1609 dp

    题目链接:http://poj.org/problem?id=1609 #include <cstdio> #include <cstring> #include <io ...

  2. poj 2506 Tiling(递推 大数)

    题目:http://poj.org/problem?id=2506 题解:f[n]=f[n-2]*2+f[n-1],主要是大数的相加; 以前做过了的 #include<stdio.h> # ...

  3. POJ 1052 Plato's Blocks

      Plato's Blocks Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 734   Accepted: 296 De ...

  4. [ACM] POJ 2506 Tiling (递归,睑板)

    Tiling Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7487   Accepted: 3661 Descriptio ...

  5. POJ 2506 Tiling

    Tiling Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7437   Accepted: 3635 Descriptio ...

  6. poj 2506 Tiling(高精度)

    Description In how many ways can you tile a 2xn rectangle by 2x1 or 2x2 tiles? Here is a sample tili ...

  7. HOJ 2124 &POJ 2663Tri Tiling(动态规划)

    Tri Tiling Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9016 Accepted: 4684 Descriptio ...

  8. POJ 2506 Tiling(递推+大整数加法)

    http://poj.org/problem?id=2506 题意: 思路:递推.a[i]=a[i-1]+2*a[i-2]. 计算的时候是大整数加法.错了好久,忘记考虑1了...晕倒. #includ ...

  9. poj 2506 Tiling(java解法)

    题目链接:id=2506">http://poj.org/problem?id=2506 本题用的java解的.由于涉及到大数问题,假设对java中的大数操作不熟悉请点这儿:链接 思路 ...

随机推荐

  1. 动态生成带参数的html标签

     "<button onclick='watchClick("+'"'+row.BOXNO + '","'+ row.VOY_NO+'" ...

  2. python——动态类型

    1.变量,对象,引用 变量是一个系统表的元素,拥有指向对象的连接的空间: 对象是分配的一块内存: 引用是自动形成的从变量到对象的指针: 类型属于对象,而不是变量 a=3;  变量a变成对象3的一个引用 ...

  3. ASUS主板 Type C 接口无效问题

    修改UEFI设置,把 USB TYPE C POWER SWITCH 改成启用

  4. jQuery工作中遇到的几个插件

    图片上传插件:uploadify 表单验证插件:formValidator

  5. 团队作业——项目Alpha版本发布

    ---恢复内容开始--- https://edu.cnblogs.com/campus/xnsy/SoftwareEngineeringClass1   https://edu.cnblogs.com ...

  6. HTML5新增的音频标签、视频标签

    我们所说的H5就是我们所说的HTML5中新增的语言标准 一.音频标签 在HTML5当中有一个叫做audio的标签,可以直接引入一段音频资源放到我们的网页当中 格式: <audio autopla ...

  7. caffe parse_log.sh

    画loss曲线需要用到此shell脚本 #!/bin/bash # Usage parse_log.sh caffe.log # It creates the following two text f ...

  8. appium---命令行启动appium

    在客户端的appium长时间运行的时候,出产生一些数据.日志有可能会对appium的内存有所增长,严重的会使appium产生崩溃,这个时候就推荐使用通过cmd进行运行appium, 安装前提需要安装N ...

  9. POP简单动画简单使用 (入门级别)

    动画可以让APP“更友好”的与用户交互,苹果提供很多的好看的动画供开发者使用,不过简单的平移.旋转.缩放.......使用起来很简单,但是想要进行一些比较复杂的动画效果,使用起来就比较难以实现,俗话说 ...

  10. attachEvent和addEventListener 的使用方法和区别

    attachEvent方法,为某一事件附加其它的处理事件.(不支持Mozilla系列)addEventListener方法 用于 Mozilla系列document.getElementById(&q ...