Advertisement
mickypinata

SMMR-T098: BSquare

May 26th, 2020
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. int row, col;
  6.  
  7. int main(){
  8.  
  9.     int x, ans;
  10.  
  11.     scanf("%d %d", &row, &col);
  12.     vector<vector<int>> memo(row + 1, vector<int>(col + 1, 0));
  13.  
  14.     ans = 1;
  15.     for(int i = 1; i <= row; ++i){
  16.         for(int j = 1; j <= col; ++j){
  17.             scanf("%d", &x);
  18.             if(i == 1 || j == 1 || x == 0){
  19.                 continue;
  20.             }
  21.             memo[i][j] = 1 + min(min(memo[i - 1][j], memo[i][j - 1]), memo[i - 1][j - 1]);
  22.             ans = max(ans, memo[i][j]);
  23.         }
  24.     }
  25.  
  26.     cout << ans;
  27.  
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement