本文整理汇总了C++中Bit::query方法的典型用法代码示例。如果您正苦于以下问题:C++ Bit::query方法的具体用法?C++ Bit::query怎么用?C++ Bit::query使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bit
的用法示例。
在下文中一共展示了Bit::query方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: solve
int solve()
{
sort(sticks, sticks + N);
int hi = sticks[N - 1];
int ans = 0;
tree.init(sticks[N - 1]);
for (int i = N - 4; i >= 2; --i) {
int a = i + 1;
for (int b = a + 1; b < N; ++b)
for (int c = b + 1; c < N; ++c) {
int v = max(1, sticks[c] - (sticks[a] + sticks[b]));
tree.add(v, 1);
}
for (int j = i - 1; j >= 1; --j)
for (int k = j - 1; k >= 0; --k) {
int v = min(hi, sticks[i] + sticks[j] + sticks[k]);
ans += tree.query(v - 1);
}
}
return ans;
}
示例2: main
int main(){
// freopen("input.txt", "r", stdin);
Node lis[SZ];
int n;
int test, val, pos, tc = 1;
scanf("%d", &test);
while( test-- ){
scanf("%d", &n);
for(int i = 1; i <= n; i++){
scanf("%d", &val);
lis[i] = Node(val, i);
}
sort(lis+1, lis+n+1);
Bit bt = Bit(n);
for(int idx = 1; idx <= n; idx++){
pos = lis[idx].pos;
bt.add(pos, 1 + bt.query(pos-1));
}
printf("Case %d: %lld\n", tc++, bt.query(n));
}
return 0;
}
开发者ID:RubelAhmed57,项目名称:problem-solution,代码行数:24,代码来源:1085+-+All+Possible+Increasing+Subsequences.cpp
示例3: main
int main()
{
int T;
scanf("%d", &T);
int ncase = 0;
while (T--) {
scanf("%d", &N);
tree.init(N);
for (int i = 1; i <= N; ++i) {
int x;
scanf("%d", &x);
tree.add(i, x);
}
printf("Case %d:\n", ++ncase);
scanf("%d", &M);
while (M--) {
int cmd;
scanf("%d", &cmd);
if (cmd == 1) {
int x, y;
scanf("%d%d", &x, &y);
printf("%d\n", tree.query(x, y));
}
else if (cmd == 2) {
int x, y, p;
scanf("%d%d%d", &x, &y, &p);
tree.add(x, -p);
tree.add(y, p);
}
}
}
return 0;
}