8000 Create 1915.cpp · dkim-coder/basic-algo-lecture@5b2902f · GitHub
[go: up one dir, main page]

Skip to content

Commit 5b2902f

Browse files
Create 1915.cpp
1 parent d64ce92 commit 5b2902f

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

Appendix E/1915.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
int n, m;
5+
string board[1005];
6+
int d[1005][1005];
7+
8+
int main(void) {
9+
ios::sync_with_stdio(0);
10+
cin.tie(0);
11+
12+
cin >> n >> m;
13+
for(int i = 0; i < n; i++)
14+
cin >> board[i];
15+
16+
for(int i = 0; i < n; i++)
17+
d[i][0] = board[i][0] - '0';
18+
19+
for(int j = 0; j < m; j++)
20+
d[0][j] = bo AA2E ard[0][j] - '0';
21+
22+
for(int i = 1; i < n; i++){
23+
for(int j = 1; j < m; j++){
24+
if(board[i][j] == '0')
25+
continue;
26+
d[i][j] = min({d[i-1][j], d[i-1][j-1], d[i][j-1]}) + 1;
27+
}
28+
}
29+
30+
int ans = 0;
31+
for(int i = 0; i < n; i++){
32+
for(int j = 0; j < m; j++)
33+
ans = max(ans, d[i][j]);
34+
}
35+
36+
cout << ans * ans << '\n';
37+
}

0 commit comments

Comments
 (0)
0