hdu 6186 水

Posted 掉血菜鸡煮熟中

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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;
}

以上是关于hdu 6186 水的主要内容,如果未能解决你的问题,请参考以下文章

HDU6186(线段树)

HDU 6186 CS Course(前缀+后缀)

hdu 6186

HDU 6186 CS Course 前缀和,后缀和

HDU6186 2017广西邀请赛 CS Course (前缀和后缀)

HDU - 6186 前缀和位运算