markdown 在线制作ppt json校验和格式化工具

POJ 1088

#include<iostream>

using namespace std;

#include<stdio.h>
int    dp(int **a,int r,int c,int i,int j,int len,int **p);
 int main(){
    //freopen("1.txt","r",stdin);
    int r;
    int c;
    int i;
    int max = 0;
    int len;
    int k;
       
    int j;
    cin>>r;
    cin>>c;
    len = 1;
    int **a=new int *[r];
    int **p = new int*[r];
    
    for(i = 0; i < r; i++)
    {
           a[i] = new int[c];
           p[i] = new int [c];
    }
     for(i=0;i<r;i++)
         for(j=0;j<c;j++){
               cin>>a[i][j];
               p[i][j] = 0;
         }
         for(i = 0; i < r; i++)
             for(j = 0; j < c; j++)
             {
                if(p[i][j] == 0)
                    len += dp(a,r,c,i,j,0,p);
                else
                    len = p[i][j];
                if(len > max)
                    max = len;
                p[i][j] = len;
            //    cout<<len<<endl;
                len = 1;
                
                //cout<<max<<endl;
             }
   cout<<max<<endl;
     
 }



int dp(int **a,int r,int c,int i,int j,int len,int **p){
            int max=0;
            if(i-1>=0){
                len = 0;
                if(a[i][j]>a[i-1][j]){
                        len++;
                        if(p[i-1][j] == 0)
                        {
                            len += dp(a,r,c,i-1,j,0,p);
                        }
                        else
                        len = p[i-1][j];
                        if(len > max)
                            max = len ;
                }
            }
            if(j-1>=0){
                len = 0;
                if(a[i][j]>a[i][j-1]){
                        len++;
                            if(p[i][j-1] == 0)
                        {
                            len += dp(a,r,c,i,j-1,0,p);
                        }
                        else
                        len =    p[i][j-1];
                        if(len > max)
                            max = len;
                }
                        
            }
            if(i+1<=r-1){
                len = 0;
                if(a[i][j]>a[i+1][j]){
                        len++;
                        if(p[i+1][j] == 0)
                        len +=dp(a,r,c,i+1,j,0,p);
                        else
                            len =p[i+1][j];
                        if(len > max)
                            max = len ;
                }
            }
            if(j+1<=c-1){
                 len = 0;
                if(a[i][j]>a[i][j+1]){
                    len++;
                    if(p[i][j+1] == 0)

                    len += dp(a,r,c,i,j+1,0,p);
                    else
                        len = p[i][j+1];
                    if(len > max)
                        max = len ;
                }
            }
            p[i][j] = max;
            p[i][j]++;
            return max;
            
  }  

 

关注我的公众号,当然,如果你对Java, Scala, Python等技术经验,以及编程日记,感兴趣的话。 

技术网站地址: vmfor.com

posted @ 2015-06-09 13:35  GavinHacker  阅读(125)  评论(0编辑  收藏  举报
markdown 在线制作ppt json校验和格式化工具