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块位置.而且该位置相 ...
随机推荐
- IO流--流转换
import java.io.*; //键盘读入 字节流转换成字符流操作 提高效率 public class io { public static void main(String[] args) t ...
- A New Tetris Game
时间限制(普通/Java):1000MS/10000MS 运行内存限制:65536KByte 总提交: 40 测试通过: 12 描述 曾经,Lele和他姐姐最喜欢,玩得最 ...
- viewDidLoad && loadView
viewDidLoad 方法在controller加载了相关的views后被调用,而不论这些views存储在nib文件里还是在loadView函数中生成. loadView 方法在控制器的 view ...
- from __future__ import absolute_import
from __future__ import absolute_import 这样以后:局部的包将不能覆盖全局的包, 本地的包必须使用相对引用了. 例: from celery import Cele ...
- Div CSS absolute与relative的区别小结
absolute:绝对定位,CSS 写法“ position: absolute; ”,它的定位分两种情况,如下: 1. 没有设定 Top.Right.Bottom.Left 的情况,默认依据父级的“ ...
- 绑定本地Service并与之通信-----之一
import android.app.Service;import android.content.Intent;import android.os.Binder;import android.os. ...
- Js练习题之查找字符串中出现最多的字符和个数
如sssfgtdfssddfsssfssss,出现最多的字符是s,出现了12次 传统写法 分析: 1.准备一个空的json,通过循环字符串的每个字符来看,如果json里没有这个字符,就在json里创建 ...
- bzoj 1821: [JSOI2010]Group 部落划分 Group
#include<cstdio> #include<iostream> #include<cmath> #include<algorithm> #def ...
- HDU 4888 Redraw Beautiful Drawings(2014 Multi-University Training Contest 3)
题意:给定n*m个格子,每个格子能填0-k 的整数.然后给出每列之和和每行之和,问有没有解,有的话是不是唯一解,是唯一解输出方案. 思路:网络流,一共 n+m+2个点 源点 到行连流量为 所给的 ...
- 常州培训 day3 解题报告
第一题: 给出数轴正半轴上N个点的坐标和其权值,给出初始体力值M,人一开始在位置0,体力值会随着走过路程的增加而增加,走多少个单位的路消耗多少体力值.到每个点可以打掉,消耗的体力值就是其权值.求 最多 ...