本文整理汇总了C++中SegmentTree::gao方法的典型用法代码示例。如果您正苦于以下问题:C++ SegmentTree::gao方法的具体用法?C++ SegmentTree::gao怎么用?C++ SegmentTree::gao使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SegmentTree
的用法示例。
在下文中一共展示了SegmentTree::gao方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(){
//Treap::Node* test = Treap::nil;
//Treap::insert(test, 1);
//cout << Treap::getRank(test, 2) << endl;
scanf("%d", &TestNum);
while (TestNum--){
scanf("%d", &n);
int m; scanf("%d", &m);
for (int i = 0; i < n; i++) scanf("%d", &a[i]);
SegmentTree::Node root(0, n - 1);
tree.init(root);
while (m--){
char buf[32]; scanf("%s", buf);
if (buf[0] == 'Q'){
int i, j, k; scanf("%d %d %d", &i, &j, &k);
printf("%d\n", getKth(i - 1, j - 1, k - 1));
}else{
int i, t; scanf("%d %d", &i, &t);
tree.gao(i -1 , i - 1).update(root, a[i - 1], t);
a[i - 1] = t;
}
//printf("new_cnt: %d\n", new_cnt);
}
tree.clear(root);
//printf("new_cnt: %d\n", new_cnt);
assert(new_cnt == 0);
//len = 1;
}
}
示例2: getKth
int getKth(int from, int to, int k){
SegmentTree::Node root(0, n - 1);
int lo = 0, hi = 1000*1024*1024;
while (lo < hi){
int m = (lo + hi + 1) / 2;
int less_than_m = tree.gao(from, to).getRank(root, m);
//printf("%d: %d %d, %d\n", m, lo, hi, less_than_m);
if (less_than_m > k) hi = m - 1;
else lo = m;
}
return lo;
};