ZOJ 1093 Monkey and Banana (LIS)解题报告
ZOJ 1093 Monkey and Banana (LIS)解题报告
题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87125#problem/B
题目:
Description
Input
Output
Sample Input
Sample Output
#include<cstdio>
#include<iostream>
#include<climits> //用INT_MAX
using namespace std;
const int M=; int box[M][];
int height[M];
int number; //互换长宽高,转换砖块的三种类型
void change(int index,int a,int b,int c)
{
box[index][]=a;
box[index][]=b;
box[index][]=c;
} int dp(int j)
{
int& ans=height[j];
if(ans!=-) //搜索过的直接返回
return ans;
for(int i=;i<=number;i++)//搜索每一层
{
if(i!=j)
{
if((box[i][]<box[j][]&&box[i][]<box[j][])||(box[i][]<box[j][]&&box[i][]<box[j][]))
{
int temp=dp(i)+box[i][];
if(temp>ans)
ans=temp;
}
}
}
if(ans==-)//最后一层未更新
ans=;
return ans;
} int main()
{
int n;
int m=;
while(scanf("%d",&n)&&n)
{
int a,b,c;
number=;
box[][]=box[][]=box[][]=INT_MAX;//地板看成无穷大砖块
for(int i=;i<=n;i++)
{
scanf("%d%d%d",&a,&b,&c);
change(++number,a,b,c);
change(++number,b,c,a);
change(++number,c,a,b);
}
for(int i=;i<=number;i++)
{
height[i]=-;
}
printf("Case %d: maximum height = %d\n",m++,dp());
}
return ;
}
每次都想完全自己写,可是自己写的都有很多错误,最后有看了别人的博客。
ZOJ 1093 Monkey and Banana (LIS)解题报告的更多相关文章
- HDU 1069 Monkey and Banana / ZOJ 1093 Monkey and Banana (最长路径)
HDU 1069 Monkey and Banana / ZOJ 1093 Monkey and Banana (最长路径) Description A group of researchers ar ...
- 随手练——ZOJ 1093 Monkey and Banana(动态规划)
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=93 一堆科学家研究猩猩的智商,给他M种长方体,每种N个. 然后,将一个 ...
- 「SDOI2014」Lis 解题报告
「SDOI2014」Lis 题目描述 给定序列 \(A\),序列中的每一项 \(A_i\) 有删除代价 \(B_i\) 和附加属性 \(C_i\). 请删除若干项,使得 \(A\) 的最长上升子序列长 ...
- ZOJ Monthly, January 2018 训练部分解题报告
A是水题,此处略去题解 B - PreSuffix ZOJ - 3995 (fail树+LCA) 给定多个字符串,每次询问查询两个字符串的一个后缀,该后缀必须是所有字符串中某个字符串的前缀,问该后缀最 ...
- zoj 2315 New Year Bonus Grant 解题报告
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1315 题目意思:Bill Hates 是公司的老总,她管辖着很多程序 ...
- hdu1069 Monkey and Banana LIS
#include<cstdio> #include<iostream> #include<algorithm> #include<queue> #inc ...
- HDU 1069 Monkey and Banana(二维偏序LIS的应用)
---恢复内容开始--- Monkey and Banana Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...
- HDU 1069 Monkey and Banana(转换成LIS,做法很值得学习)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1069 Monkey and Banana Time Limit: 2000/1000 MS (Java ...
- zoj 2313 Chinese Girls' Amusement 解题报告
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1313 题目意思:有 N 个人(编号依次为1~N)围成一个圆圈,要求求 ...
随机推荐
- poj 1206
/** 题意: 给定一序列,置换k次之后 输出其状态 置换: 考察循环节长度, 思路: 分别求出每个元素的循环节的大小,用k 模其大小,大的k次之后的位置, 输出即可 **/ #include < ...
- Paragraph Vector在Gensim和Tensorflow上的编写以及应用
上一期讨论了Tensorflow以及Gensim的Word2Vec模型的建设以及对比.这一期,我们来看一看Mikolov的另一个模型,即Paragraph Vector模型.目前,Mikolov以及B ...
- OSG消锯齿
osg::DisplaySettings::instance()->setNumMultiSamples(); 在osg+mfc下成功实现抗锯齿,在程序初始化的时候,即在osg控制类中,我的 ...
- Thread-safety with regular expressions in Java
As mentioned in our introduction to the Pattern and Matcher classes, the Java regular expression API ...
- 强化:把treeview的QString路径转换为QModelIndex节点,有了节点就什么都好办了
http://doc.qt.io/qt-4.8/qdirmodel.html#index-2 甚至还能直接调用setData: setData(const QModelIndex &index ...
- Delphi XE的RTTI增强,动态Hook某些内部事件
Delphi2010之后的RTTI做了很大休整,现在用起来很爽了哦.甚至可以获取某些类的内部私有单元,然后为其赋值!讲这个RTTI增强的,可以参考网上的多个博客内容,我列举一下: Delphi2010 ...
- Android网络框架技术
网络相关1. Asynchronous Http Client for Android Android异步Http请求项目地址:https://github.com/loopj/android-asy ...
- hdu 4741 Save Labman No.004(2013杭州网络赛)
http://blog.sina.com.cn/s/blog_a401a1ea0101ij9z.html 空间两直线上最近点对. 这个博客上给出了很好的点法式公式了...其实没有那么多的tricky. ...
- Android学习路线(二十)运用Fragment构建动态UI
要在Android系统上创建一个动态或者多面板的用户界面,你须要将UI组件以及activity行为封装成模块.让它可以在你的activity中灵活地切换显示与隐藏. 你可以使用Fragment类来创建 ...
- XML DOM 节点
来自:w3cschool菜鸟教程 在 DOM 中,XML 文档中的每个成分都是一个节点. DOM 节点 根据 DOM,XML 文档中的每个成分都是一个节点. DOM 是这样规定的: 整个文档是一个文档 ...