hdu 6186 水

hdu 6186   CS Course

求个前后缀就好了

#include<bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:102400000,102400000")
#define rep(i,a,b) for (int i=a; i<=b; ++i)
#define per(i,b,a) for (int i=b; i>=a; --i)
#define mes(a,b)  memset(a,b,sizeof(a))
#define INF 0x3f3f3f3f
#define MP make_pair
#define PB push_back
#define fi  first
#define se  second
typedef long long ll;
const int N = 100005;

int n, q, a[N], pi, s11[N], s12[N], s21[N], s22[N], s31[N], s32[N];
int main()
{
    while(~scanf("%d%d", &n, &q))
    {
        s11[0]=s12[n+1]=(1<<31)-1;
        s21[0]=s22[n+1]=0;
        s31[0]=s32[n+1]=0;
        rep(i,1,n)
        {
            scanf("%d", &a[i]);
            s11[i] = s11[i-1]&a[i];
            s21[i] = s21[i-1]|a[i];
            s31[i] = s31[i-1]^a[i];
        }
        per(i,n,1)
        {
            s12[i] = s12[i+1]&a[i];
            s22[i] = s22[i+1]|a[i];
            s32[i] = s32[i+1]^a[i];
        }
        rep(i,1,q)
        {
            scanf("%d", &pi);
            printf("%d %d %d\n", s11[pi-1]&s12[pi+1], s21[pi-1]|s22[pi+1], s31[pi-1]^s32[pi+1]);
        }
    }

    return 0;
}
posted @ 2017-09-14 21:55  v9fly  阅读(157)  评论(0编辑  收藏  举报