Pagini recente » Cod sursa (job #1230484) | Cod sursa (job #969933) | Cod sursa (job #1185944) | Cod sursa (job #1795700) | Cod sursa (job #2056487)
#include <iostream>
#include <fstream>
#define INF 1000000002
using namespace std;
int n, m, i, j, k, a, b, c, ma[502][502], d[502][502], mx;
int main()
{
ifstream fin ("plantatie.in");
ofstream fout ("plantatie.out");
fin >> n >> m;
for(i = 1; i <= n; i++)
{
ma[i][0] = INF;
for(j = 1; j <= n; j++)
{
fin >> ma[i][j];
for(k = j - 1; ma[i][k] < ma[i][j]; k = d[i][k]);
d[i][j] = k;
}
}
for(k = 1; k <= m; k++)
{
fin >> a >> b >>c;
for(i = a; i <= a + c - 1; i++)
{
for(j = b + c - 1; j >= b; j = d[i][j])
mx = ma[i][j];
//fout << mx << " ";
}
//fout << "\n";
fout << mx << "\n";
}
return 0;
}