shalivitalya

Задача 2, если не пройдёт, покажите нормально выходные данны

Mar 25th, 2020
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. const int N = 1e3+5;
  6.  
  7. int n, m, ans, l = 1e9, r = -1e9, u = 1e9, d = 1e9;
  8. bool M[N][N];
  9.  
  10. int main(){
  11.     ios_base::sync_with_stdio(0);
  12.     cin.tie(0); cout.tie(0);
  13.     cin >> n >> m;
  14.     for(int i = 1; i <= n; ++i){
  15.         for(int j = 1; j <= m; ++j){
  16.             cin >> M[i][j];
  17.             if(M[i][j]){
  18.                 l = min(j,l);
  19.                 r = max(j,r);
  20.                 u = min(i,u);
  21.                 d = max(i,u);
  22.             }
  23.         }
  24.     }
  25.     cout << u-2 << " " << l-2 << " " << d << " " << r;
  26.  
  27.     return 0;
  28. }
Add Comment
Please, Sign In to add comment