Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <string>
- #include <fstream>
- size_t maxZeroRectangle(size_t rows, size_t columns)
- {
- std::string key;
- std::vector<std::vector<int>> field;
- std::getline(std::cin, key);
- for (size_t i = 0; rows > i; ++i)
- {
- std::getline(std::cin, key);
- std::vector<int> vector;
- vector.reserve(key.size());
- for (int j = 0; j < key.size(); ++j)
- {
- vector.push_back((key[j] - 47) % 2);
- }
- field.push_back(vector);
- vector.clear();
- }
- int result = -1;
- for (size_t i = 0; i < rows; ++i)
- {
- for (size_t j = 0; j < columns; ++j)
- {
- if (!field[i][j] || i == 0)
- continue;
- field[i][j] += field[i - 1][j];
- }
- int x = 0, y = 0, temp = 0;
- int m = *std::max_element(field[i].begin(), field[i].end());
- for (int j = 1; j <= m; ++j)
- {
- for (size_t k : field[i])
- {
- if (j > k)
- {
- x = std::max(x, y);
- y = 0;
- } else
- {
- if (k == 0)
- {
- x = std::max(x, y);
- y = 0;
- } else
- y++;
- }
- }
- x = std::max(x, y);
- temp = (int) (std::max(temp, j * x));
- x = 0;
- y = 0;
- }
- result = std::max(temp, result);
- }
- return result;
- }
- int main()
- {
- size_t height, width;
- std::cin >> height >> width;
- std::cout << maxZeroRectangle(height, width);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement