hiho week 19 register

Ended

Participants:317

Verdict:Accepted
Score:100 / 100
Submitted:2014-11-10 00:45:56

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 <stdio.h>
const int MaxNode = 1000000;
const int MaxNumber = 0x7fffffff;
struct lineNode {
    int l, r;
    int lchild, rchild;
    int minus;
};
lineNode a[2 * MaxNode];
int n, Q;
int weight[MaxNode + 1];
int treeNumber = 0;
void changeWeight(int pos, int num, int weight) {
    if (a[pos].l == a[pos].r) {
        a[pos].minus = weight;
        return;
    }
    if (num > (a[pos].l + a[pos].r) / 2)
        changeWeight(a[pos].rchild, num, weight);
    else
        changeWeight(a[pos].lchild, num, weight);
    int lminus = a[a[pos].lchild].minus;
    int rminus = a[a[pos].rchild].minus;
    a[pos].minus = lminus < rminus ? lminus : rminus;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX