「NLOI Round1」千本桜
验题人的
若
若
这个做法中所有运算均可以用内置的位运算符来完成,因而复杂度为
fun fact:这个做法的运行效率远优于 std 。赛前我询问过是否要专门卡一下,不过最后因为这只是道 T2 所以放过去了带
代码如下:
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int a[N],s[N];
int main(){
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int n,q;cin>>n>>q;
for(int i=1;i<=n;i++){
cin>>a[i];
s[i]=s[i-1]^a[i];
}
for(int i=1;i<=q;i++){
int op,k,l,r;cin>>op>>k>>l>>r;
if(op==0){
cout<<(k&(s[r]^s[l-1]))<<"\n";
}else{
cout<<((r-l+1)&1)*k+((~k)&(s[r]^s[l-1]))<<"\n";
}
}
return 0;
}