Advertisement
Guest User

Mikołaj Dziok - wyspy

a guest
Sep 21st, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. bool sea[1010][1010];
  6.  
  7. int main()
  8. {
  9.     int n,m;
  10.     cin >> n >> m;
  11.     string boi;
  12.     int res = 0;
  13.     for (int i = 0;i<n;i++)
  14.     {
  15.         cin >> boi;
  16.         for (int j = 0;j<m;j++)
  17.         {
  18.             if (boi[j] == '1')
  19.             {
  20.                 sea[i+1][j+1] = 1;
  21.                 int temp = sea[i][j+1] + sea[i+1][j];
  22.                 if (temp == 0)
  23.                     res++;
  24.                 if (temp == 2)
  25.                     if (sea[i][j] == 0)
  26.                         res--;
  27.             }
  28.         }
  29.     }
  30.     cout << res;
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement