Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- const int N = 110;
- int n, m;
- int a[N][N];
- /*
- A B C
- D o E
- F G H
- o (x, y)
- F (x + 1, y - 1)
- */
- int dx[8] = {1, 1, 1, -1, -1, -1, 0, 0}; // F G H A B C D E
- int dy[8] = {-1, 0, 1, -1, 0, 1, -1, 1};
- signed main() {
- cin >> n >> m;
- for (int i = 1; i <= n; i ++) {
- for (int j = 1; j <= m; j ++) {
- cin >> a[i][j];
- }
- }
- int ans = 0;
- for (int x = 1; x <= n; x ++) {
- for (int y = 1; y <= m; y ++) {
- bool flag = 1;
- // (x, y)
- for (int i = 0; i < 8; i ++) {
- int nx = dx[i] + x;
- int ny = dy[i] + y;
- // (nx, ny)
- if (nx < 1 || nx > n || ny < 1 || ny > m) continue;
- if (a[x][y] < a[nx][ny]) {
- flag = 0;
- }
- }
- if (flag) ans ++;
- }
- }
- cout << ans << endl;
- return 0;
- }
- /*
- 0 0 0 0 0 0
- 0 150 190 170 180 0
- 0 145 150 165 175 0
- 0 140 178 149 190
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement