In fact, the beginning of this topic I did not do it because I do not know & What do you mean, I thought it was a plus and
This problem is actually meant to make constructing an array, it's an interval according to a number of bit and see will not conflict.
Know that after the easy to handle, create a 0 arrays, each query on | it, then the query interval with bit and see if character does not meet]
Why | do?
This is how to consider the operation of the &
In binary bits, only on one bit of two numbers are 1 & 1 is out, so there is a very obvious problem, & out of the number does not necessarily equal to every number in the interval
But in their bins, & out of a certain number of bits are equal, so each time the query to query the number of corresponding bits | on the line
Then the board is the tree line right here can not be used Fenwick tree, think about why
1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 const int N=1e6+10; 6 typedef long long ll; 7 ll tree[N],lazy[N]; 8 void updata(int rt,int l,int r,ll w){ 9 tree[rt]=tree[rt]|w; 10 lazy[rt]=tree[rt]|w; 11 } 12 void pushdown(int rt,int l,int r){ 13 int mid=l+r>>1; 14 updata(rt<<1,l,mid,lazy[rt]); 15 updata(rt<<1|1,mid+1,r,lazy[rt]); 16 lazy[rt]=0; 17 } 18 void modify(int rt,int l,int r,int s,int t,ll w){ 19 if(s<=l&&r<=t){ 20 updata(rt,l,r,w); 21 return; 22 } 23 pushdown(rt,l,r); 24 int mid=l+r>>1; 25 if(s<=mid)modify(rt<<1,l,mid,s,t,w); 26 if(t>mid)modify(rt<<1|1,mid+1,r,s,t,w); 27 tree[rt]=tree[rt<<1]&tree[rt<<1|1]; 28 } 29 ll query(int rt,int l,int r,int s,int t){ 30 if(s<=l&&t>=r)return tree[rt]; 31 pushdown(rt,l,r); 32 int mid=l+r>>1; 33 if(t<=mid)return query(rt<<1,l,mid,s,t); 34 else if(s>mid)return query(rt<<1|1,mid+1,r,s,t); 35 else return query(rt<<1,l,mid,s,t)&query(rt<<1|1,mid+1,r,s,t); 36 } 37 int main(){ 38 int m,n,t;bool flag; 39 freopen("kuai.in","r",stdin); 40 freopen("kuai.out","w",stdout); 41 scanf("%d",&t); 42 while(t--){ 43 flag=1; 44 memset(tree,0,sizeof(tree)); 45 scanf("%d%d",&n,&m); 46 for(int i=1;i<=m;i++){ 47 int l,r; 48 ll w; 49 scanf("%d%d%lld",&l,&r,&w); 50 modify(1,1,n,l,r,w); 51 ll data=query(1,1,n,l,r); 52 if(data!=w)flag=0; 53 } 54 if(flag)printf("YES\n"); 55 else printf("NO\n"); 56 } 57 return 0; 58 }