hiho week 19 register

Ended

Participants:317

Verdict:Accepted
Score:100 / 100
Submitted:2014-11-09 17:42:23

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 1000001
using namespace std;
struct Node{
    int L,R,V;
};Node Tree[MAXN<<2];
void Build(int id,int L,int R){
    Tree[id].L=L;
    Tree[id].R=R;
    Tree[id].V=0;
    if(L==R)    return;
    int M=(L+R)>>1;
    Build(id<<1,L,M);
    Build(id<<1|1,M+1,R);
}
void Update(int id,int pos,int W){
    int L=Tree[id].L,R=Tree[id].R;
    if(L==R){
        Tree[id].V=W;
        return;
    }
    int M=(L+R)>>1;
    if(pos<=M) Update(id<<1,pos,W);
    else Update(id<<1|1,pos,W);
    Tree[id].V=min(Tree[id<<1].V,Tree[id<<1|1].V);
}
int Query(int id,int Left,int Right){
    int L=Tree[id].L,R=Tree[id].R;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX