From e5a25ecaeb8197808784cdfe7417b03dcea2a210 Mon Sep 17 00:00:00 2001 From: Kirito <1362050620@qq.com> Date: Mon, 22 Aug 2016 00:27:18 +0800 Subject: [PATCH] Create 3225_niuox.cpp From http://blog.csdn.net/niuox/article/details/9664487 --- POJ/3225_niuox.cpp | 121 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 POJ/3225_niuox.cpp diff --git a/POJ/3225_niuox.cpp b/POJ/3225_niuox.cpp new file mode 100644 index 0000000..4bcdb7a --- /dev/null +++ b/POJ/3225_niuox.cpp @@ -0,0 +1,121 @@ +#include +#include + +using namespace std; + +#define Maxn 132000 + +//宏定义最好全加上括号 +#define lx (x<<1) +#define rx ((x<<1) | 1) +#define MID ((l + r)>>1) + +int cover[Maxn<<2]; +int XOR[Maxn<<2]; +bool vis[Maxn+5]; + +void FXOR(int x) +{ + if(cover[x]!=-1) cover[x] ^= 1; + //注意是else + else XOR[x] ^= 1; +} +void pushDown(int x) +{ + //cover[x] == -1代表x节点的覆盖工作已经结束 + if(cover[x]!=-1) + { + cover[lx] = cover[rx] = cover[x]; + XOR[lx] = XOR[rx] = 0;//既然已经覆盖异或标记就清零 + cover[x] = -1; + } + if(XOR[x]) + { + FXOR(lx); + FXOR(rx); + XOR[x] = 0; + } +} + +void update(int L,int R,char op,int l,int r,int x) +{ + if(L<=l && r<=R) + { + if(op == 'U') + { + cover[x] = 1; + XOR[x] = 0; + } + //op == 'I'的情况,由于L<=l && r<=R,所以不需要讨论 + else if(op == 'D') + { + cover[x] = 0; + XOR[x] = 0; + } + else if(op == 'C') FXOR(x); + else if(op == 'S') FXOR(x); + return; + } + pushDown(x); + if(L<=MID) update(L,R,op,l,MID,lx); + else if(op == 'I' || op == 'C') cover[lx] = XOR[lx] = 0; + if(MID>1,(e+1)>>1,e&1?')':']'); + s = -1; + flag = true; + } + } + } + if(!flag) printf("empty set"); + puts(""); + return 0; +}