POJ 1609 Tiling Up Blocks
| Time Limit: 1000MS | Memory Limit: 10000K | |
| Total Submissions: 4675 | Accepted: 1824 |
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个砖块的长和宽,只有当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的更多相关文章
- poj 1609 dp
题目链接:http://poj.org/problem?id=1609 #include <cstdio> #include <cstring> #include <io ...
- poj 2506 Tiling(递推 大数)
题目:http://poj.org/problem?id=2506 题解:f[n]=f[n-2]*2+f[n-1],主要是大数的相加; 以前做过了的 #include<stdio.h> # ...
- POJ 1052 Plato's Blocks
Plato's Blocks Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 734 Accepted: 296 De ...
- [ACM] POJ 2506 Tiling (递归,睑板)
Tiling Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7487 Accepted: 3661 Descriptio ...
- POJ 2506 Tiling
Tiling Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7437 Accepted: 3635 Descriptio ...
- poj 2506 Tiling(高精度)
Description In how many ways can you tile a 2xn rectangle by 2x1 or 2x2 tiles? Here is a sample tili ...
- HOJ 2124 &POJ 2663Tri Tiling(动态规划)
Tri Tiling Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9016 Accepted: 4684 Descriptio ...
- POJ 2506 Tiling(递推+大整数加法)
http://poj.org/problem?id=2506 题意: 思路:递推.a[i]=a[i-1]+2*a[i-2]. 计算的时候是大整数加法.错了好久,忘记考虑1了...晕倒. #includ ...
- poj 2506 Tiling(java解法)
题目链接:id=2506">http://poj.org/problem?id=2506 本题用的java解的.由于涉及到大数问题,假设对java中的大数操作不熟悉请点这儿:链接 思路 ...
随机推荐
- LibreOJ #2130. 「NOI2015」软件包管理器
内存限制:256 MiB 时间限制:1000 ms 标准输入输出 题目类型:传统 评测方式:文本比较 上传者: 匿名 树链剖分+线段树 屠龙宝刀点击就送 #include <vector> ...
- SAP ERP和C4C Account和Contact的双向同步
Account和Contact是C4C里唯一支持可以和ERP进行双向同步的主数据类别. C4C里创建一个Account:Mouser Electronics 在C4C里保存Account,自动同步到E ...
- [学习笔记] C++ 历年试题解析(二)--程序题
发现程序题也挺有价值的. 顺便记录下来几道. 1.题目 #include <iostream> #include <cstring> using namespace ① std ...
- mangoDB笔记
1. 查询 db.表.find().pretty() find(querry,project) pretty()格式化显示 findOne() 返回一条结果 比较 db.Decl_In.find( ...
- 2018.3.16 Ubuntu 解决中文乱码问题
一.乱码的样子类似: °²Àï¿ü ÒÁ¸ñÀ³Ï£ÑÇ˹,°²Àï¿ü ÒÁ¸ñÀ³Ï£ÑÇ˹ 这种乱码称为Gedit中文乱码 打开部分Windows下的txt文本文件的时候,中文显示为乱码.但 ...
- C07 模块化开发信息管理系统案例
目录 需求分析 问题分析 开发阶段 需求分析 总体需求 学员信息管理系统支持以下功能 增加学员信息功能 删除学员信息功能 查询学员信息功能 修改学员信息功能 输出所有学员信息功能 退出系统 其他需求 ...
- 《毛毛虫团队》第九次团队作业:BETA冲刺与团队项目验收
一:实验名称:Beta冲刺与验收准备 二:实验目的与要求 (1)掌握软件黑盒测试技术: (2)学会编制软件项目总结PPT.项目验收报告: (3)掌握软件项目验收内容,验收流程. 三.实验内容与步骤 任 ...
- laydate时间控件绑定回调事件
onclick="laydate({istime: true, format: 'YYYY-MM-DD',choose:checkDate});" //回调函数内容 functio ...
- axure的基本使用方法(侧边导航栏的制作)
1.创建一个动态面板control 2.在home中创建动态面板homepage和movepage并且完成布局 3.给home添加移动事件 4.给按钮添加点击事件 5.大功告成
- USACO08FEB Hotel
题目传送门 线段树维护区间 线段树结构体 struct zzz{ int l,r,mi; //l为以左端点的为起点的最长子串 //r为以右端点为终点的最长子串 //mi是区间内部的最长子串 }tree ...