Cod sursa(job #332575)

Utilizator ssergiussSergiu-Ioan Ungur ssergiuss Data 18 iulie 2009 17:43:02
Problema Plantatie Scor 50
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.83 kb
# include <algorithm>
using namespace std;

# define DIM 501

int n, m, x, y, l, a[ DIM ][ DIM ];

inline int max ( int x, int y ) {

    if ( x > y )
        return x;

    return y;
}

int calc () {

    int i, j, rez;

    rez = 0;
    for ( i = x; i < x + l; ++ i )
        for ( j = y; j < y + l; ++ j )
            rez = max ( rez, a[ i ][ j ] );

    return rez;
}

void solve () {

    int i, j;

    scanf ( "%d%d", &n, &m );
    for ( i = 1; i <= n; ++ i )
        for ( j = 1; j <= n; ++ j )
            scanf ( "%d", &a[ i ][ j ] );
    for ( i = 0; i < m; ++ i ) {

        scanf ( "%d%d%d", &x, &y, &l );
        printf ( "%d\n", calc () );
    }
}

int main () {

    freopen ( "plantatie.in", "r", stdin );
    freopen ( "plantatie.out", "w", stdout );

    solve ();

    return 0;
}