首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

bzoj1057: [ZJOI2007]棋盘打造

2013-08-13 
bzoj1057: [ZJOI2007]棋盘制作const int N 2010int n, m, Ans1, Ans2, top, sta1[N], sta2[N], h[N]bo

bzoj1057: [ZJOI2007]棋盘制作
const int N = 2010;int n, m, Ans1, Ans2, top, sta1[N], sta2[N], h[N];bool Dat[N][N];inline void Input() { scanf("%d%d", &n, &m); int x; For(i, 1, n)For(j, 1, m) {scanf("%d", &x);Dat[i][j] = x;}}inline void push(int h) { int x = 1; while(sta2[top] > h) { Ans1 = max(sqr(min(sta2[top], sta1[top])), Ans1), Ans2 = max(sta2[top] * sta1[top], Ans2); if(sta2[--top] >= h) sta1[top] += sta1[top+1]; else {x += sta1[top+1];break;} } if(sta2[top] == h) sta1[top] += x; else sta2[++top] = h, sta1[top] = x;}inline void Solve() {int now = 0; Ans1 = 1, Ans2 = 1; For(i, 1, m) { if (Dat[1][i] + Dat[1][i-1] == 1) now++;else now = 1; Ans2 = max(now, Ans2), h[i] = 1; } For(i, 2, n) { For(j, 1, m) { if(Dat[i][j] + Dat[i][j-1] != 1) push(0); if(Dat[i][j] + Dat[i-1][j] == 1) h[j]++;else h[j] = 1; push(h[j]); } push(0); } printf("%d\n%d\n", Ans1, Ans2);}int main() {#ifndef ONLINE_JUDGESETIO("1057");#endifInput();Solve();return 0;}

?

热点排行