Lang:G++
Edit12345678910111213141516171819202122232425262728293031#include <iostream>#include <string.h>const int N = 100100;int tree[N];int id[N];int lowbit(int x) {return x & -x;}void modify(int x, int pos, int n) {while (pos <= n) {tree[pos] += x;pos += lowbit(pos);}}int query(int pos, int n) {int sum = 1;while (pos > 0) {sum += tree[pos];pos -= lowbit(pos);}return pos == 0 || pos == n + 1 ? sum + 1 : sum;}bool check(int L, int R, int n) {if (L < 0 || R > n + 1) return false;int sum = query(R - 1, n) - query(L, n);