Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- string map[1001];
- int dp[1001][1001];
- int n,m;
- int res=0;
- int main() {
- cin>>n>>m;
- for(int i=0; i<n; i++) {
- cin>>map[i];
- }
- for(int i=0; i<n; i++) {
- for(int j=0; j<m; j++) {
- if(map[i][j]=='1') {
- if(res<1)
- res=1;
- dp[i][j]=1;
- if(i-1>=0 && j-1>=0) {
- if(dp[i-1][j-1]!=0 && dp[i][j-1]!=0 && dp[i-1][j]!=0) {
- int t=0;
- if(dp[i-1][j-1]==dp[i][j-1] && dp[i-1][j]==dp[i-1][j-1] && dp[i][j-1] == dp[i-1][j-1]) {
- t=dp[i-1][j-1]+1;
- } else {
- t=min(min(dp[i-1][j-1], dp[i][j-1]), dp[i-1][j])+1;
- }
- dp[i][j]=t;
- if(res<t)
- res=t;
- }
- }
- }
- }
- }
- cout<<res*res<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement