I can't figure out why the final push (i+1,0) and then find out that no pop is lost is definitely not counted. So the last is to calculate these. 、。
#include <cstdio> #include <cstring> #include <cctype> #include <algorithm>using namespace std; #define REP (I,s,t) for (int. i=s;i<=t;i++) #define DWN (i,s,t) for (int i=s;i>=t;i--) #define CLR (x,c) memset (X,c, sizeof (x)) int read () {int X=0;char c=getchar (); while (!isdigit (c)) C=getchar (); while (IsDigit (c)) x=x*10+c-' 0 ', C=getchar (); return x;} const int nmax=2005;int a[nmax][nmax],b[nmax][nmax],n,m;struct node{int x,h; Node () {} node (int x,int h): X (x), H (h) {};}; Node S[nmax];void print () {Rep (i,1,n) {rep (j,1,m) printf ("%d", A[i][j]);p rintf ("\ n"); } rep (I,1,n) {rep (j,1,m) printf ("%d", B[i][j]);p rintf ("\ n"); }}void maxs (int &a,int b) {if (a<b) a=b;} int main () {N=read (), M=read (); Rep (I,1,n) Rep (j,1,m) {a[i][j]=read (); if ((i+j)%2) a[i][j]^=1; } Rep (I,1,n) Rep (j,1,m) b[i][j]=a[i][j]==0?b[i][j-1]+1:0; Print (); int ans=0,res=0,top,tmp; Rep (j,1,m) {top=0; Rep (i,1,n+1) { Tmp=i; while (Top&&s[top].h>b[i][j]) {maxs (Ans,min (i-s[top].x,s[top].h) *min (i-s[top].x,s[top].h)); Maxs (res,s[top].h* (i-s[top].x)); tmp=s[top--].x; } s[++top]=node (Tmp,b[i][j]); }} Rep (I,1,n) Rep (j,1,m) a[i][j]^=1; Rep (I,1,n) Rep (j,1,m) b[i][j]=a[i][j]==0?b[i][j-1]+1:0; Print (); Rep (j,1,m) {top=0; Rep (i,1,n+1) {tmp=i; while (Top&&s[top].h>b[i][j]) {maxs (Ans,min (i-s[top].x,s[top].h) *min (i-s[top].x,s[top].h)); Maxs (res,s[top].h* (i-s[top].x)); tmp=s[top--].x; } s[++top]=node (Tmp,b[i][j]); }} printf ("%d\n%d\n", ans,res); return 0;}
1057: [ZJOI2007] Checkerboard production time limit:20 Sec Memory limit:162 MB
submit:2365 solved:1174
[Submit] [Status] [Discuss] Description
Chess is one of the oldest game games in the world, with Chinese Weiqi, chess and Japanese chess. It is said that chess originated from the thought of the I Ching, the chessboard is a 8*8 size of black and white square, corresponding to 8,864 gua, black and white corresponding yin and yang. And our protagonist, the little Q, is a chess enthusiast. As a top-notch player, he was not content with the usual chessboard and rules, so he and his good friend, Little W, decided to expand the chessboard to fit their new rules. Little Q found a rectangular piece of paper made up of squares of n*m, each of which was painted with one of the two colors of black and white. Little Q wanted to cut some of this paper as a new chessboard, and of course he wanted the chessboard to be as big as possible. But little Q has not decided to find a square chessboard or a rectangular chessboard (of course, the chessboard must be black and white, that is, the adjacent lattice is different), so he hopes to find the largest square checkerboard area and the largest rectangular checkerboard area, which will determine which is better. So little Q found the upcoming National Information Science Competition you, can you help him? The first line of Input contains two integers n and m, each representing the length and width of the rectangular paper. The next n rows contain a 01 matrix of N * m, representing the color of the rectangle paper (0 for White and 1 for black). Output contains two lines, each containing an integer. The first behavior can be found in the area of the largest square checkerboard, and the second behavior can be found in the area of the largest rectangular checkerboard (note that squares and rectangles can intersect or contain). Sample Input3 3
1 0 1
0 1 0
1 0 0Sample Output4
6HINT
N, m≤2000
Source [Submit] [Status] [Discuss]
bzoj1057: [ZJOI2007] Board making