-
Notifications
You must be signed in to change notification settings - Fork 651
Expand file tree
/
Copy path1915.cpp
More file actions
40 lines (32 loc) · 786 Bytes
/
Copy path1915.cpp
File metadata and controls
40 lines (32 loc) · 786 Bytes
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
// Authored by : BaaaaaaaaaaarkingDog
// Co-authored by : -
// http://boj.kr/80adad0cf6bf4d8b832294601db3caac
#include <bits/stdc++.h>
using namespace std;
int n, m;
string board[1005];
int d[1005][1005];
int main(void) {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for(int i = 0; i < n; i++)
cin >> board[i];
for(int i = 0; i < n; i++)
d[i][0] = board[i][0] - '0';
for(int j = 0; j < m; j++)
d[0][j] = board[0][j] - '0';
for(int i = 1; i < n; i++){
for(int j = 1; j < m; j++){
if(board[i][j] == '0')
continue;
d[i][j] = min({d[i-1][j], d[i-1][j-1], d[i][j-1]}) + 1;
}
}
int ans = 0;
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++)
ans = max(ans, d[i][j]);
}
cout << ans * ans << '\n';
}