poj 3494
来源:互联网 发布:什么相机软件最好 编辑:程序博客网 时间:2024/06/18 15:12
#include <iostream>#include <fstream>#include <cstring>using namespace std;int M,N;int map[2000][2000];int a[2000];int b[2000];int res;void init(){memset(map, 0, sizeof(map) );memset(a, 0, sizeof(a) );memset(b, 0, sizeof(b) );res = 0;int i,j,t;for(i = 0; i < M; ++i){for(j = 0; j < N; ++j){scanf("%d",&t);map[i][j] = t;}}}int getOne(int n){int i,max = 0, finish = 0;for(i=0; i<N; ++i){if(a[i] == 1)++max;else{if(finish < max ) finish = max;max = 0;}}if(finish < max ) finish = max;return finish * n;}void putA(int nowLine){int i;for(i=0; i<N; ++i){a[i] = map[nowLine][i];}}void putB(int nowLine){int i;for(i=0; i<N; ++i){b[i] = map[nowLine][i];}}void aYUb(){int i;for(i=0; i<N; ++i){a[i] = a[i]&b[i];}}void nextLine(int nowLine){//printf("LINE : %d\n",nowLine);putA(nowLine);int n = 1,max;while(n <= M){max = getOne(n);//printf("max = %4d%4d\n",max, n);if(max == 0)return ;if(res < max) res = max;putB(nowLine + n);aYUb();++n;}}int main(){//freopen("a.txt","r",stdin);//freopen("b.txt","w",stdout);int j=0,i=0;while(scanf("%d%d",&M, &N)==2){init();for(i=0; i<M; ++i){nextLine(i);}printf("%d\n", res);}}
超时了,是因为,MN,范围太大了,有2000位,没有一个语言的一个类型可以分配500个字节给int,只有退而求其次,用字符串(本来想用一个整数的),
模似与运算。因此,就超时了;
阅读全文
0 0
- POJ 3494
- 【POJ】3494
- poj 3494
- POJ 2559 最大矩形面积 poj 3494
- Poj 3494 (dp)
- poj 3494 单调栈
- poj 3494 单调栈
- POJ 3494(可以过)
- POJ
- poj
- POJ
- POJ
- poj
- poj
- POJ
- POJ
- poj
- POJ
- Unity 画虚线
- 互斥锁加条件变量解决生产者消费者问题
- 杭电ACM OJ 1020 Encoding 输入一串字符 判断每种字符个数 我犯了个错误定义数组长度的错误
- Ubuntu在校园网(锐捷)中进行的网络设置
- 提取跨多行的函数声明的办法
- poj 3494
- HDU6231 K-th Number
- java线程安全之单例&多线程(十一)
- 简单算法之冒泡排序
- codeforces 891-A. Pride Codeforces Round #446 (Div. 2) C. Pride
- Mac 系统 使用SourceTree拉取Gitlab项目配置
- day 25 shell相关命令及特殊符
- Mysql数据库的api介绍
- 递归解决汉诺塔问题