本篇小重点:异或树https://www.luogu.com.cn/problem/P2846 用异或的0和1来模拟开关操作。一个区间只有亮灯和灭灯,所以异或之后区间亮灯的数量就是异或前区间灭灯的数量。
#include
#define int long long
using namespace std;
const int maxn=1e5+5;
int a[maxn],n,m;
struct node
{
int val,lazy; //val记录一个区间内亮灯的数量,lazy与1异或来模拟明暗灯
}sg[maxn
关注
打赏