Advertisement
AntonGorokhov

Untitled

Oct 6th, 2022
477
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define DBG
  6.  
  7. int main()
  8. {
  9.     int n;
  10.     cin >> n;
  11.     string mas[n];
  12.     for(auto &i : mas) cin >> i;
  13.     vector < vector <int> > v(n, vector <int>(n, 0));
  14.     for(int i = 0; i < n ; ++i){
  15.         for(int j = 0; j < n; ++j){
  16.             if(mas[i][j] == '1'){
  17.                 v[i][j] = 1;
  18.             }
  19.         }
  20.     }
  21.     int ans = 1;
  22.     for(int i = 1; i < n; ++i){
  23.         for(int j = 1; j < n; ++j){
  24.             if(v[i][j] == 1){
  25.                 v[i][j] = min(min(v[i-1][j], v[i][j-1]), v[i-1][j-1]) + 1;
  26.                 ans = max(ans, v[i][j]);
  27.             }
  28.         }
  29.     }
  30.     cout << ans*ans;
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement