QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#95871 | #4389. Copy | 3360550356 | AC ✓ | 139ms | 5188kb | C++14 | 1.1kb | 2023-04-12 10:08:26 | 2023-04-12 10:08:30 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=100010;
bitset<N>ans;
int a[N];
struct que{
int oper,l,r;
};
que q[N];
int n;
void solve(){
int k;
scanf("%d %d",&n,&k); //左移或右移
ans.reset();
for(int i=1;i<=n;i++){
scanf("%d",&a[i]);
}
for(int i=1;i<=k;i++){
scanf("%d",&q[i].oper);
if(q[i].oper==1){
scanf("%d %d",&q[i].l,&q[i].r);
}
if(q[i].oper==2){
scanf("%d",&q[i].l);
}
}
for(int i=k;i>=1;i--){
int oper=q[i].oper;
int l=q[i].l;
int r=q[i].r;
if(oper==2){
ans[l]=1-ans[l];
}
else {
auto a = ans & (~bitset<N>(0) >> (N - r - 1));
auto b = ans & (~bitset<N>(0) << (r + 1));
ans = a ^ (b >> (r + 1 - l));
}
}
long long res=0;
for(int i=1;i<=n;i++){
if(ans[i]) res^=a[i];
}
printf("%lld\n",res);
return ;
}
int main(){
int T;
cin>>T;
while(T--){
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 139ms
memory: 5188kb
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