import java.util.*; public class MaxMatrix{ private int[][] arr; private int[][] compress; public MaxMatrix(int[][] _arr){ arr = _arr; getCompress(); } public int getResult(){ int max=0; for (int i=0; i> stack = new Stack>(); LinkedList curr; boolean isEqual=false; for (int i=0; i(); curr.offerLast(i); stack.push(curr); }else{ while(!stack.isEmpty()){ curr = stack.peek(); if(temp[curr.peekLast()] < temp[i]){ break; }else if(temp[curr.peekLast()] == temp[i]){ curr.offerLast(i); isEqual=true; break; }else{ curr = stack.pop(); for (int v:curr ) { result[v][0] = stack.isEmpty()? -1 :stack.peek().peekLast(); result[v][1] = i; } } } if(!isEqual){ curr = new LinkedList(); curr.offerLast(i); stack.push(curr); } } } while(!stack.isEmpty()){ curr = stack.pop(); for (int v:curr ) { result[v][0] = stack.isEmpty()? -1 :stack.peek().peekLast(); result[v][1] = -1; } } return result; } private int getMaxSub(int[][] temp,int[] org){ //第一行[x][y]:存放开始坐标 //第二行[x][y]:存放结束坐标 //第三行[2][0]:存放值 //int[][] result = new int[3][2]; int startX; int startY; int endX; int endY; int max=0; for (int i=0; i