From 3a85a14a1795a0082ecd3c24e8f7e21097443b4b Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Tue, 30 Nov 2021 13:01:22 +0800 Subject: [PATCH] =?UTF-8?q?P1387=20=E6=9C=80=E5=A4=A7=E6=AD=A3=E6=96=B9?= =?UTF-8?q?=E5=BD=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit R63951894 --- Luogu/P1387/P1387.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Luogu/P1387/P1387.cpp diff --git a/Luogu/P1387/P1387.cpp b/Luogu/P1387/P1387.cpp new file mode 100644 index 00000000..752f3b78 --- /dev/null +++ b/Luogu/P1387/P1387.cpp @@ -0,0 +1,38 @@ +#include + +using std::cin; +using std::cout; +using std::endl; + +int n, m, ans; +bool g[105][105]; + +bool check(int x1, int y1, int x2, int y2) { + for (int i = x1; i <= x2; i++) { + for (int j = y1; j <= y2; j++) { + if (!g[i][j]) return false; + } + } + return true; +} + +int main() { + cin >> n >> m; + for (int i = 1; i <= n; i++) { + for (int j = 1; j <= m; j++) { + cin >> g[i][j]; + } + } + for (int i = 1; i <= n; i++) { + for (int j = 1; j <= m; j++) { + for (int k = 1; k <= std::min(n, m); k++) { + if (i + k > n || j + k > m) break; + if (check(i, j, i + k - 1, j + k - 1)) { + ans = std::max(ans, k); + } + } + } + } + cout << ans << endl; + return 0; +}