Cod sursa(job #3038250)

Utilizator stefypluStefan Plugaru stefyplu Data 27 martie 2023 09:36:21
Problema Plantatie Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.91 kb
#include <fstream>
#include <cmath>
using namespace std;
ifstream cin("f.in");
ofstream cout("f.out");
int rmq[503][503][10]; //rmq[X][Y][DIMENSIUNE 2^L]
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n, q;
    cin>>n>>q;
    for (int i=1; i<=n; i++)
        for (int j=1; j<=n; j++)
            cin>>rmq[i][j][0];
    int val=(int)log2(n);
    int putere=1;
    for (int h=1; h<=val; h++, putere*=2)
        for (int i=1; i<=n; i++)
            for (int j=1; j<=n; j++)
            {
                rmq[i][j][h]=max(rmq[i+putere/2][j][h-1], rmq[i][j+putere/2][h-1]);
                rmq[i][j][h]=max(rmq[i][j][h], rmq[i][j][h-1]);
                rmq[i][j][h]=max(rmq[i][j][h], rmq[i+putere/2][j+putere/2][h-1]);
            }
    while (q--)
    {
        int st, dr, lung;
        cin>>st>>dr>>lung;
        int lg2=log2(lung);
    }
    return 0;
}