HDU 1069 Monkey and Banana(最大递增子串)

占坑(在上课所以先不写思路了)

//#include<iostream>
//#include<stdio.h>
//using namespace std;
//typedef unsigned long long uLL;
//const uLL base1 = 131;
//const uLL base2 = 233;
//const int hmaxn=1005;
//const int lmaxn=1005;
//const int xhmaxn=55;
//const int xlmaxn=55;
//int n, m;
//char mp[hmaxn][lmaxn];
//char mpsearch[xhmaxn][xlmaxn];
//uLL has[hmaxn][lmaxn];
//uLL p1[hmaxn], p2[lmaxn];
//
//void init()
//{
//    p1[0] = p2[0] = 1;
//    for(int i = 1; i <= 505; i ++) {
//        p1[i] = p1[i-1]*base1;
//        p2[i] = p2[i-1]*base2;
//    }
//}
//
//void Hash()
//{
//    has[0][0] = 0;
//    has[0][1] = 0;
//    has[1][0] = 0;
//    for(int i = 1; i <= n; i ++) { //对列进行哈希
//        for(int j = 1; j <= m; j ++) {
//            has[i][j] = has[i][j-1]*base1 + mp[i-1][j-1] - 'a';
//        }
//    }
//    for(int i = 1; i <= n; i++) {
//        for(int j = 1; j <= m; j ++) { //对行进行哈希
//            has[i][j] = has[i-1][j]*base2 + has[i][j];
//        }
//    }
//}
//int check(int hash,int x,int y)
//{
//    int cnt = 0;
//    for(int i = x; i <= n; i ++) {
//        for(int j = y; j <= m; j ++) {
//            uLL k = has[i][j] - has[i-x][j]*p2[x] - has[i][j-y]*p1[y] + has[i-x][j-y]*p1[x]*p2[y];
//            if(k ==hash)cnt ++;
//        }
//    }
//    return cnt;
//}
//int main()
//{
//    init();
//    int k,x,y;
//    int count=0;
//    while(cin>>n>>m>>k>>x>>y)
//    {
//        count++;
//        cout<<"Case "<<count<<": ";
//        for(int i=0;i<n;i++)scanf("%s",mp[i]);
//        Hash();
//        int ans=0;
//        while(k--)
//        {
//            int hash=0;
//            int hass[xhmaxn];
//            for(int i=0;i<x;i++)scanf("%s",mpsearch[i]);
//            for(int i = 0; i <x; i ++) { //对列进行哈希
//                hass[i]=0;
//                for(int j = 0; j <y; j ++) {
//                    hass[i] = hass[i]*base1 +mpsearch[i][j]- 'a';
//                }
//            }
//            for(int i = 0; i < x; i++) {
//                hash= hash*base2 + hass[i];
//            }
//            ans+=check(hash,x,y);
//        }
//        cout<<ans<<endl;
//    }
//}
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
const int maxn=95;
struct node{
    int x, y, z;
    node(int a=0, int c=0, int k=0) : x(a), y(c), z(k) {}
}miao[maxn];
int dp[maxn];
bool cmp(node a,node c)
{if(a.x=c.x)
return a.y<c.y;
else return a.x<c.x;}
int main() {
    int n;int k=0;
    while (cin >> n&&n) {
        k++;
        cout<<"Case "<<k<<": maximum height = ";
        int x, y, z;
        int ans = 0;
        for (int i = 0; i < n; i++) {
            cin >> x >> y >> z;
            miao[i * 3] = node(max(x, y), min(x, y), z);
            miao[i * 3 + 1] = node(max(x, z), min(x, z), y);
            miao[i * 3 + 2] = node(max(y, z), min(y, z), x);
        }
        sort(miao, miao + n * 3, cmp);
        dp[0] = 0;
        for (int i = 0; i < n * 3; i++)
        {dp[i] = miao[i].z;
            int temp = 0;
        for (int j = 0; j < i; j++) {
                if (miao[j].x < miao[i].x && miao[j].y < miao[i].y) {
                    temp = max(temp, dp[j]);
                }
            }
            dp[i] += temp;
            ans = max(dp[i], ans);}
        cout << ans << endl;
    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值