摘要:
"P2023 [AHOI2009]维护序列" 指定一个区间 加上或者乘以 V, 查询一个区间所有元素和%P 与纯加法线段树不同的是,lazy_tag 的传递 (x + y) v = x v + y v。 所以每次乘法,都要把加法的lazy_tag v 而加法与加法线段树的操作一样 c++ inclu 阅读全文
摘要:
"P3372 【模板】线段树 1" c++ include include typedef long long LL; using namespace std; const int MAXN = 1000000+5; LL arr[MAXN]; struct seg { int l, r, lz; 阅读全文
摘要:
"牛客 20806 Bad Hair Day" 题目意思 牛1向右看,看得见 牛2,3,4, 看不见 牛5 以及 牛5之后的牛。 求每个牛能看见牛的个数。 1 2 3 4 5 6 O O OO O OOO O OOOOOO 题解:维护一个单调递减栈,只要求每个最大值的右区间即可)。 include 阅读全文
摘要:
"教程地址" C++ int lowbit(int i) { return i & ( i); } int sum(int i) {//区间[1,i]的和 int ans = 0; while (i 0) { ans += c[i]; i = lowbit(i); } return ans; } v 阅读全文