-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path836.cpp
56 lines (48 loc) · 1.5 KB
/
836.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <algorithm>
#include <array>
#include <iostream>
#include <string>
int count_ones(const std::string line, const int size, int start)
{
int count = 0;
while (start < size && line[start] == '1') {
++count;
++start;
}
return count;
}
int main(void)
{
int num_cases, size, max_count, dx, dy;
std::string buffer;
std::array<std::string, 26> matrix;
getline(std::cin, buffer);
num_cases = std::stoi(buffer);
getline(std::cin, buffer);
while (num_cases--) {
size = 0;
while (getline(std::cin, matrix[size])) {
if (matrix[size].size() == 0) break;
++size;
}
max_count = 0;
for (int i = 0; max_count < (size - i) * size && i < size; ++i) {
for (int j = 0; max_count < (size - i) * (size - j) && j < size;
++j) {
if (matrix[i][j] == '1') {
dx = 1;
dy = count_ones(matrix[i], size, j);
if (max_count < dx * dy) max_count = dx * dy;
while (i + dx < size && matrix[i + dx][j] == '1') {
dy = std::min(dy, count_ones(matrix[i + dx], size, j));
++dx;
if (max_count < dx * dy) max_count = dx * dy;
}
}
}
}
std::cout << max_count << std::endl;
if (num_cases) std::cout << std::endl;
}
return 0;
}