Untitled

mail@pastecode.io avatar
unknown
plain_text
5 months ago
1.1 kB
1
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],n,m,ans = -MOD,pre[maxn][maxn],sum,i,j,k,l;
void inp()
{
    cin >> m >> n;
    For(i,1,m)
    For(j,1,n)
    {
        cin >> a[i][j];
        pre[i][j] = pre[i][j] + pre[i-1][j] + pre[i][j-1] - pre[i-1][j-1] + a[i][j];
    }
}

void solve()
{
    For(h1,1,m)
    For(c1,1,n)
    For(h2,h1,m)
    For(c2,c1,n)
    {
        sum = pre[h2][c2] - pre[h1-1][c2] - pre[h2][c1-1] + pre[h1-1][c1-1];
        if(ans < sum)
        {
            ans = sum;
            i = h1; j = c1; k = h2; l = c2;
        }
    }
    cout << ans << endl;
    cout << i << " " << j << " " << k << " " << l;

}
int main()
{
    ios_base:: sync_with_stdio(0);
    cin.tie(0);
    if(fopen("bai7.inp","r")){
        freopen("bai7.inp","r",stdin);
    }
    inp();
    solve();
}
Leave a Comment