Skip to content

Commit b83426a

Browse files
committed
[Week03] BOJ_14925: 목장건설하기
1 parent d6957b9 commit b83426a

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#include <iostream>
2+
3+
using namespace std;
4+
5+
int n, m, ret;
6+
int arr[1001][1001], dp[1001][1001];
7+
8+
int main() {
9+
ios::sync_with_stdio(false);
10+
cin.tie(NULL); cout.tie(NULL);
11+
12+
cin >> m >> n;
13+
14+
for (int i = 1; i <= m; i++) {
15+
for (int j= 1; j <= n; j++) {
16+
cin >> arr[i][j];
17+
}
18+
}
19+
20+
for (int i = 1; i <= m; i++) {
21+
for (int j = 1; j <= n; j++) {
22+
if (!arr[i][j]) {
23+
if (!dp[i - 1][j - 1] || !dp[i][j - 1] || !dp[i - 1][j]) {
24+
dp[i][j] = 1;
25+
}
26+
else {
27+
dp[i][j] = min(min(dp[i - 1][j - 1], dp[i][j - 1]), dp[i - 1][j]) + 1;
28+
}
29+
ret = max(ret, dp[i][j]);
30+
}
31+
}
32+
}
33+
34+
cout << ret << '\n';
35+
36+
return 0;
37+
}

0 commit comments

Comments
 (0)