Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4. string map[1001];
  5. int dp[1001][1001];
  6. int n,m;
  7. int res=0;
  8. int main() {
  9. cin>>n>>m;
  10. for(int i=0; i<n; i++) {
  11. cin>>map[i];
  12. }
  13. for(int i=0; i<n; i++) {
  14. for(int j=0; j<m; j++) {
  15. if(map[i][j]=='1') {
  16. if(res<1)
  17. res=1;
  18. dp[i][j]=1;
  19. if(i-1>=0 && j-1>=0) {
  20. if(dp[i-1][j-1]!=0 && dp[i][j-1]!=0 && dp[i-1][j]!=0) {
  21. int t=0;
  22. 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]) {
  23. t=dp[i-1][j-1]+1;
  24. } else {
  25. t=min(min(dp[i-1][j-1], dp[i][j-1]), dp[i-1][j])+1;
  26. }
  27. dp[i][j]=t;
  28. if(res<t)
  29. res=t;
  30. }
  31. }
  32. }
  33. }
  34. }
  35. cout<<res*res<<endl;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement