题目链接

题意;给个数组,每次询问一个区间你可以挑任意个数的数字异或和 然后在或上k的最大值

题解:线性基不知道的先看这个,一个线性基可以log的求最大值把对应去区间的线性基求出来然后用线段树维护线性基

#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define maxn 100009
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
int read()
{
    char ch=' ';
    ;
    ')
        ch=getchar();
    ')
    {
        ans=ans*+ch-';
        ch=getchar();
    }
    return ans;
}
struct ac{
   ];
   void init(){
      memset(a,,sizeof(a));
   }
   bool add(int x){
       ;j>=;j--){
          <<j)){
             if(!a[j]){
                a[j]=x;
                break;
             }
             x^=a[j];
          }
       }
       ;
   }
   int query(){
      ;
      ;j>=;j--){
         if((x^a[j])>x){
            x^=a[j];
         }
      }
      return x;
   }
   ac merge_LB(ac x){
        ac ret;
        ;i<=;i++){
            ret.a[i]=a[i];
        }
        ;i<=;i++){
            ret.add(x.a[i]);
        }
        return ret;
   }
}tre[maxn*];
int b[maxn];
void build(int l,int r,int in){
  tre[in].init();
  if(l==r){
    tre[in].add(b[l]);
    return ;
  }
  ;
  build(l,mid,);
  build(mid+,r,+);
  tre[].merge_LB(tre[+]);
}
ac query(int l,int r,int x,int y,int in){
   if(l==x&&r==y){
        return tre[in];
    }
    ;
    //ac ret;ret.init();
    ));
    ,y,+));
    ).merge_LB(query(mid+,r,mid+,y,+));
}
int main(){
   int t;
   cin>>t;
   while(t--){
      int n,m,k;
     //scanf("%d%d%d",&n,&m,&k);
      n=read();m=read();k=read();
      k=~k;
      ;j<=n;j++){
         scanf("%d",&b[j]);
         b[j]&=k;
      }
      k=~k;
      build(,n,);
      ;j<m;j++){
          int l,r;
          //scanf("%d%d",&l,&r);
          l=read();r=read();
          ac ans=query(l,r,,n,);
          int an=ans.query();
          an|=k;
          printf("%d\n",an);
      }
   }
}

ACM-ICPC 2017 Asia Xi'an A XOR (线性基+线段树思想)的更多相关文章

  1. ACM-ICPC 2017 西安赛区现场赛 A. XOR(线性基+线段树)

    题目链接:https://nanti.jisuanke.com/t/20749 参考题解:https://blog.csdn.net/Lee_w_j__/article/details/8266418 ...

  2. 计蒜客 A1607 UVALive 8512 [ACM-ICPC 2017 Asia Xi'an]XOR

    ICPC官网题面假的,要下载PDF,点了提交还找不到结果在哪看(我没找到),用VJ交还直接return 0;也能AC 计蒜客题面 这个好 Time limit 3000 ms OS Linux 题目来 ...

  3. ACM-ICPC 2017 Asia Xi'an

    ACM-ICPC 2017 Asia Xi'an Solved A B C D E F G H I J K 7/11 O O Ø O O ? O O O for passing during the ...

  4. ACM ICPC 2017 Warmup Contest 9 I

    I. Older Brother Your older brother is an amateur mathematician with lots of experience. However, hi ...

  5. ACM ICPC 2017 Warmup Contest 9 L

    L. Sticky Situation While on summer camp, you are playing a game of hide-and-seek in the forest. You ...

  6. luogu P2574 XOR的艺术 (线段树)

    luogu P2574 XOR的艺术 (线段树) 算是比较简单的线段树. 当区间修改时.\(1 xor 1 = 0,0 xor 1 = 1\)所以就是区间元素个数减去以前的\(1\)的个数就是现在\( ...

  7. HDU 5475(2015 ICPC上海站网络赛)--- An easy problem(线段树点修改)

    题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=5475 Problem Description One day, a useless calculato ...

  8. codeforces 22E XOR on Segment 线段树

    题目链接: http://codeforces.com/problemset/problem/242/E E. XOR on Segment time limit per test 4 seconds ...

  9. Xor && 线性基练习

    #include <cstdio> #include <cstring> ; ; int cnt,Ans,b,x,n; inline int Max(int x,int y) ...

随机推荐

  1. Azure系列2.1.7 —— BlobRequestOptions

    (小弟自学Azure,文中有不正确之处,请路过各位大神指正.) 网上azure的资料较少,尤其是API,全是英文的,中文资料更是少之又少.这次由于公司项目需要使用Azure,所以对Azure的一些学习 ...

  2. Js中instanceof 的用法

    在 JavaScript 中,判断一个变量的类型尝尝会用 typeof 运算符,在使用 typeof 运算符时采用引用类型存储值会出现一个问题,无论引用的是什么类型的对象,它都返回 “object”. ...

  3. 思维导图,UML图,程序流程图制作从入门到精通

    工具: https://www.processon.com/ 第一 用例图 第二 时序图 第三 流程图

  4. mybatis:数据持久层框架

    mybatis是一个持久层的框架,是Apache下的顶级项目. mybatis托管到goolecode下,再后来托管到GitHub下:https://github.com/mybatis/mybati ...

  5. codeforces401C

    Team CodeForces - 401C Now it's time of Olympiads. Vanya and Egor decided to make his own team to ta ...

  6. Nginx memcached应用层反向代理

    L:105 Module ngx_http_memcached_module 模块默认编译进Nginx

  7. 安装使用nginx

    nginx的优势 是c语言开发的一个web框架 官方声称支持10W+的并发 天下武功 唯快不破 tengine+ uwsgi(多进程) + django 你公司的技术栈是什么样? centos7 + ...

  8. sws_getContext函数参数介绍

    原型: SwsContext *sws_getContext(int srcW, int srcH, enum AVPixelFormat srcFormat, int dstW, int dstH, ...

  9. P1028 数的计算

    P1028 题目描述 我们要求找出具有下列性质数的个数(包含输入的自然数n): 先输入一个自然数n(n≤1000),然后对此自然数按照如下方法进行处理: 不作任何处理; 在它的左边加上一个自然数,但该 ...

  10. IDEA 根据 Mysql 自动生成

    1 找到 没有的,file--project structure--modules--+--JPA 2  找到如下 添加Mysql连接,记得 Text Connecting一下看看 然后刷新,就可以出 ...