From fd072571c6227472778143365a0ba2db7234ad33 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Mon, 26 Aug 2024 11:53:52 +0800 Subject: [PATCH] =?UTF-8?q?P10719=20[GESP202406=20=E4=BA=94=E7=BA=A7]=20?= =?UTF-8?q?=E9=BB=91=E7=99=BD=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://www.luogu.com.cn/record/174781514 --- Luogu/P10719/P10719.cpp | 53 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Luogu/P10719/P10719.cpp diff --git a/Luogu/P10719/P10719.cpp b/Luogu/P10719/P10719.cpp new file mode 100644 index 00000000..2fc6ebe4 --- /dev/null +++ b/Luogu/P10719/P10719.cpp @@ -0,0 +1,53 @@ +#include +#include + +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::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::max() ? 0 : ans) << endl; + + return 0; +}