[USACO15JAN]牛的矩形Cow Rectangles
极大子矩形·单调栈·二分
题解:
先单调栈求极大子矩形,对于每个再二分压缩掉空白的部分。
Code:
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#define D(x) cout<<#x<<" = "<<x<<" "
#define E cout<<endl
using std::vector;
using std::min;
using std::max;
using std::cout;
using std::endl;
const int N = 7;
const int INF = 0x3f3f3f3f;
struct Rect{
int x1,y1,x2,y2;
Rect(){}
Rect(int _x1,int _y1,int _x2,int _y2){ x1=_x1; y1=_y1; x2=_x2; y2=_y2; }
int getSquare(){ return (x2-x1)*(y2-y1); }
void print(){ D(x1); D(y1); D(x2); D(y2); D(getSquare()); E; }
};
int m; int g[N+5][N+5],sum[N+5][N+5];
int height[N+5][N+5],left[N+5][N+5],right[N+