Untitled

mail@pastecode.io avatar
unknown
plain_text
5 months ago
1.1 kB
7
Indexable
#include <bits/stdc++.h>
#define endl '\n'
#define maxn 105
#define TASK bai1
#define For(i,a,b) for ( int i = a; i <= b; i++ )
#define Ford(i,a,b) for ( int i = a; i >= b; i-- )
#define MOD 100000000000007

using namespace std;
int a[maxn][maxn],m,n,d = 0;
void inp()
{
    cin >> m >> n;
    For(i,1,m)
    For(j,1,n)
        cin >> a[i][j];
}
bool check(int h, int c)
{
    int kt = 0;
    For(i,h,m)
    if (a[h][c] < a[i][c])
    {
        kt++;
        break;
    }
    For(i,c,n)
    if (a[h][c] < a[h][i])
    {
        kt++;
        break;
    }
    Ford(i,h,1)
    if (a[h][c] < a[i][c])
    {
        kt++;
        break;
    }
    Ford(i,c,1)
    if (a[h][c] < a[h][i])
    {
        kt++;
        break;
    }
    if(kt == 4) return false;
    return true;
}
void solve()
{
    For(i,1,m)
    For(j,1,n)
    if(check(i,j)) d++;
    cout << d;
}
int main()
{
    ios_base:: sync_with_stdio(0);
    cin.tie(0);
    if(fopen("bai13.inp","r")){
        freopen("bai13.inp","r",stdin);
    }
    inp();
    solve();
    return 0;
}
Leave a Comment