During the War of Resistance Against Japan, tunnel warfare was carried out extensively in the vast areas of north China Plain. Generally speaking, villages connected by tunnels lay in a line. Except the two at the ends, every village was directly con…
#include <iostream> #include <stdio.h> #include <string.h> #define lson rt<<1,L,mid #define rson rt<<1|1,mid+1,R using namespace std; ; int n,q; long long num[maxn]; struct Node{ long long sum,add; bool lazy; }tree[maxn<&l…
题意:给你一些区间操作,让你输出最后得出的区间. 解法:区间操作的经典题,借鉴了网上的倍增算法,每次将区间乘以2,然后根据区间开闭情况做微调,这样可以有效处理开闭区间问题. 线段树维护两个值: cov 和 rev ,一个是覆盖标记,0表示此区间被0覆盖,1表示被1覆盖,-1表示未被覆盖, rev为反转标记,rev = 1表示反转,0表示不翻转 所以集合操作可以化为如下区间操作: U l r: 把区间[l,r]覆盖成1I l r: 把[0,l)(r,MAX]覆盖成0 D l r: …