topcoder-srm610-div2-550(暴力乱搞)
来源:互联网 发布:linux tar命令unzip 编辑:程序博客网 时间:2024/06/06 22:36
给你一个01矩阵,求其中最大的01交替的矩阵
由于n最大才100,所以直接暴力乱搞
先求出第i行,所有列往上的合法长度,然后枚举以第j列为最左边的列,计算可以得到的最大矩阵
/************************************************************************* > File Name: 2.cpp > Author: ALex > Mail: zchao1995@gmail.com > Created Time: 2015年05月07日 星期四 15时07分58秒 ************************************************************************/#include <functional>#include <algorithm>#include <iostream>#include <fstream>#include <cstring>#include <cstdio>#include <cmath>#include <cstdlib>#include <queue>#include <stack>#include <map>#include <bitset>#include <set>#include <vector>using namespace std;const double pi = acos(-1.0);const int inf = 0x3f3f3f3f;const double eps = 1e-15;typedef long long LL;typedef pair <int, int> PLL;int ok[110][110];class TheMatrix { public: int MaxArea(vector <string> mat) { memset(ok, 0, sizeof(ok)); int n = mat.size(); int m = mat[0].length(); for (int i = 0; i < m; ++i) { ok[i][0] = 1; for (int j = 1; j < n; ++j) { if (mat[j][i] == mat[j - 1][i]) { ok[i][j] = 1; } else { ok[i][j] = ok[i][j - 1] + 1; //the ith row of jth col } } } int size = 0; for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { int mins = ok[j][i]; size = max(size, mins); int flag = mat[i][j] - '0'; for (int k = j + 1; k < m; ++k) { if (flag == mat[i][k] - '0') { break; } flag ^= 1; mins = min(mins, ok[k][i]); size = max(size, (k - j + 1) * mins); } } } return size; }};
0 0
- topcoder-srm610-div2-550(暴力乱搞)
- topcoder-srm610-div2-1000(dp)
- Topcoder SRM523-527(DIV2)
- 小朋友学TopCoder(3):SRM144 DIV2 550-point
- TopCoder SRM 144 DIV2(550-point)
- TopCoder SRM 144 DIV2 550points
- topcoder SRM 513 DIV2
- TopCoder SRM 543 DIV2
- topcoder 544 div2
- Topcoder SRM548 div2
- topcoder-srm-233-div2
- Topcoder SRM Div2 Level2
- topcoder-595-div2
- topcoder srm606 div2
- topcoder srm607 div2
- TopCoder SRM 144 div2
- TOPCODER SRM 612 DIV2
- TOPCODER SRM 613 DIV2
- 一起talk Vim吧(第十三回:Vim刀法总结)
- 不同作用域的重名问题
- 程序员的《学习之道》
- Distinct Subsequences -- leetcode
- javascript中字符串常用操作总结、JS字符串操作大全
- topcoder-srm610-div2-550(暴力乱搞)
- servlet开发5-servlet返回html界面
- 4.zookeeper原理解析-数据存储之FileTxnLog& FileTxnSnapLog工具
- 不包含适合于入口点的静态“Main”方法
- [转]Unicode与UTF-8互转(C语言实现)
- 第五章类和对象2015-05-11
- C/C++中extern关键字详解
- php中jsonp的跨域实例
- FPS游戏开发练习1