0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-09-16 19:25:25 +00:00

P10719 [GESP202406 五级] 黑白格

https://www.luogu.com.cn/record/174781514
This commit is contained in:
Baoshuo Ren 2024-08-26 11:53:52 +08:00
parent 7cd1049391
commit fd072571c6
Failed to extract signature

53
Luogu/P10719/P10719.cpp Normal file
View File

@ -0,0 +1,53 @@
#include <iostream>
#include <limits>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 105;
int n, m, k;
bool g[N][N];
int s[N][N];
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m >> k;
for (int i = 1; i <= n; i++) {
std::string s;
cin >> s;
for (int j = 1; j <= m; j++) {
g[i][j] = s[j - 1] == '1';
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + g[i][j];
}
}
int ans = std::numeric_limits<int>::max();
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
for (int k = i; k <= n; k++) {
for (int l = j; l <= m; l++) {
if (s[k][l] - s[i - 1][l] - s[k][j - 1] + s[i - 1][j - 1] >= ::k) {
ans = std::min(ans, (k - i + 1) * (l - j + 1));
}
}
}
}
}
cout << (ans == std::numeric_limits<int>::max() ? 0 : ans) << endl;
return 0;
}