6 #define maxn 150000 //default maxn=150000
15 virtual int cmp(int p
, int q
) { //default: Range-Min-Query
16 return p
<q
?p
:q
; //you have to inherit my class
17 } //and give your own cmp function
20 for (int i
=1; i
<=n
; i
++) table
[i
][0]=data
[i
];
21 for (int i
=1; i
<=m
; i
++)
22 for (int j
=1; j
<=n
; j
++)
23 table
[j
][i
]=cmp(table
[j
][i
-1],table
[(j
+(1<<(i
-1)))][i
-1]);
25 int query(int p
, int q
) {
27 return cmp(table
[p
][m
],table
[q
-(1<<m
)+1][m
]);
29 #ifdef DEBUG //an easter egg
31 for (int i
=1; i
<=n
; i
++) printf("%d",table
[i
][1]);