Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///Задача 1
- #include <iostream>
- using namespace std;
- const int N = 1e3+5;
- int n, m, ans;
- bool M[N][N];
- int main(){
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- cin >> n >> m;
- for(int i = 1; i <= n; ++i)
- for(int j = 1; j <= m; ++j)
- cin >> M[i][j];
- for(int i = 1; i <= n; ++i)
- for(int j = 1; j<= m; ++j)
- ans += M[i][j]&&M[i+1][j]&&M[i][j+1]&&M[i][j-1]&&M[i-1][j]&&
- M[i-1][j-1]&& M[i+1][j+1] && M[i-1][j+1] && M[i+1][j-1];
- cout << ans;
- return 0;
- }
Add Comment
Please, Sign In to add comment