QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#48547#4389. Copyzzxzzx123AC ✓83ms5340kbC++171.0kb2022-09-14 15:20:102022-09-14 15:20:13

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-09-14 15:20:13]
  • 评测
  • 测评结果:AC
  • 用时:83ms
  • 内存:5340kb
  • [2022-09-14 15:20:10]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1e5+50;
bitset<N>ans;
bitset<N>flag0;//全部都是0 
bitset<N>flag1;//全部都是1 
int a[N];
struct node{
	int s;
	int x,y;
}e[N];
int main(){
	int t;
	scanf("%d",&t);
	flag1.set();
	while(t--){
		int n,q;
		scanf("%d%d",&n,&q);
		for(int i=1;i<=n;i++){
			scanf("%d",&a[i]);
		}
		int s,x,y;
		for(int i=1;i<=q;i++){
			scanf("%d",&s);
			if(s==1){
				scanf("%d%d",&x,&y);
			}else{
				scanf("%d",&x);
			}
			e[i]={s,x,y};
		}
		ans.reset();
		for(int i=q;i;i--)
		{
			s=e[i].s,x=e[i].x,y=e[i].y;
			if(s==1){
				int len=y-x+1;
				int ll=y+1,rr=min(N-1,y+len);
				bitset<N> g=(flag1>>(y+1))<<(y+1);//这一段只有(rr+1,到N-1)是1
				bitset<N>k=g;
				k.flip();
				g&=ans;			
				ans=k&ans;//后面的全部清零 				
				ans^=(g>>len);
			}else {
				ans[x]=ans[x]^1;
			}
		}
		int res=0;
		for(int i=1;i<=n;i++){
			if(ans[i]){
				res^=a[i];
			}
		}
		printf("%lld\n",res);
	}
	return 0;
} 

詳細信息

Test #1:

score: 100
Accepted
time: 83ms
memory: 5340kb

input:

2
5 10
14138491 23289232 33892225 43531245 54436322
1 1 4
2 2
2 3
2 4
2 5
1 2 4
2 2
2 3
2 4
2 5
99990 99990
493133979 94198606 751145654 147404311 601524088 744747426 561746143 212260573 241231749 810352224 81276441 382492450 18779020 317505899 880615584 654793240 417574821 822313301 140569958 69317...

output:

28631531
787379207

result:

ok 2 lines