思路:
一开始很SB的一直在想位运算,后来看了一下别人怎么写的,才发现这就是个前缀和后缀和垃圾题
P.S.卡多组输入
代码附:
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e5+10;
int a[N],XOR;
int andP[N],orP[N];
int andS[N],orS[N];
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n,q,x;
while(cin>>n>>q)
{
andP[0]=andS[n+1]=(1<<32)-1;
orP[0]=orS[n+1]=0;
XOR=0;
for(int i=1; i<=n; ++i)
{
cin>>a[i];
andP[i]=andP[i-1]&a[i];
orP[i]=orP[i-1]|a[i];
XOR^=a[i];
}
for(int i=n; i; --i)
{
andS[i]=andS[i+1]&a[i];
orS[i]=orS[i+1]|a[i];
}
while(q--)
{
cin>>x;
cout<<(andP[x-1]&andS[x+1])<<" "<<(orP[x-1]|orS[x+1])<<" "<<(XOR^a[x])<<endl;
}
}
return 0;
}