BOJ/C++
가장 큰 정사각형
IamToday
2020. 2. 13. 01:00
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#include <iostream>
#include <vector>
#include <string>
#define MAXX 1002
using namespace std;
int map[MAXX][MAXX], dp[MAXX][MAXX];
int n, m;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n >> m;
for (int i = 1; i <= n; i++) {
string s;
cin >> s;
for (int j = 0; j < s.size(); j++) {
map[i][j+1] = s[j] - 48;
}
}
int maxN = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (map[i][j]) {
//1일 때
dp[i][j] = min(dp[i - 1][j - 1], min(dp[i - 1][j], dp[i][j - 1])) + map[i][j];
maxN = max(maxN, dp[i][j]);
}
}
}
cout << maxN * maxN << '\n';
return 0;
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|