private static int calMaxLength(int rN,int cN,int length){
		flag[rN][cN]=true;
		int up=0,down=0,left=0,right=0;
		if (rec[rN][cN]==-1){
			if ((rN-1)>=0 && (mat[rN-1][cN]<mat[rN][cN])){
				up=calMaxLength(rN-1,cN,length+1);
			}
			if ((rN+1)<r && (mat[rN+1][cN]<mat[rN][cN])){
				down=calMaxLength(rN+1,cN,length+1);
			}
			if ((cN-1)>=0 && (mat[rN][cN-1]<mat[rN][cN])){
				left=calMaxLength(rN,cN-1,length+1);
			}
			if ((cN+1)<c && (mat[rN][cN+1]<mat[rN][cN])){
				right=calMaxLength(rN,cN+1,length+1);
			}
			rec[rN][cN]=max(up,down,left,right)+1;
		}
		return rec[rN][cN];
	}