Cod sursa(job #1326956)

Utilizator cosmin.pascaruPascaru Cosmin cosmin.pascaru Data 26 ianuarie 2015 11:32:00
Problema Arbori de intervale Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.93 kb
#include <fstream>

using namespace std;

#define NMAX 100005

ifstream fin ("arbint.in");
ofstream fout ("arbint.out");

int a[4*NMAX];
int n, m;

void update(int st, int dr, int poz, int nod, int val);
int query(int st, int dr, int poz1, int poz2, int nod);

int main()
{
    fin >> n >> m;
    for (int i = 1; i <= n; ++i)
    {
        fin >> x;
        update(1, n, i, 1, x);
    }
    for (int i = 1; i <= m; ++i)
    {
        fin >> c >> x >> y;
        if (c == 0) fout << query(1, n, x, y, 1);
        else update(1, n, a, 1, b);
    }

    return 0;
}

void update(int st, int dr, int poz, int nod, int val)
{
    int mij =(st + dr)>>1;
    if (a[nod] < val) a[nod] = val;
    if (st < dr)
        if (mij >= poz) update(st, mij, poz, 2*nod, val);
            else update(mij+1, dr, poz, 2*nod+1, val);
}
int query(int st, int dr, int poz1, int poz2, int nod)
{
    if (poz1 <= st && dr <= poz2)
}