http://codeforces.com/contest/842/problem/D

树 二进制(路径,每个节点代表一位)

 #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <time.h>
#include <string>
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <vector>
#include <bitset>
#include <ext/rope>
#include <algorithm>
#include <iostream>
using namespace std;
#define ll long long
#define minv 1e-6
#define inf 1e9
#define pi 3.1415926536
#define E 2.7182818284
const ll mod=1e9+;//
const int maxn=1e5+; bool tr[<<]={};//19+2
int f[];
int w=; int main()
{
int n,m,a,b,i,j,k,value;
scanf("%d%d",&n,&m);
while (n--)
{
scanf("%d",&a);
b=a;
for (i=w;i>=;i--)
{ f[i]=a & ;
a>>=;
}
j=;
for (i=;i<=w;i++)
{
j<<=;
if (f[i]==)
j++;
}
tr[j]=;
} for (i=(<<w)-;i>=;i--)
tr[i]=tr[i<<]&tr[i<<|]; b=;
while (m--)
{
scanf("%d",&a);
b=a^b; a=b;
for (i=w;i>=;i--)
{
f[i]=a & ;
a>>=;
}
j=;
k=<<(w-);
value=;
for (i=;i<=w;i++)
{
j<<=;
if (!tr[j+f[i]])
{
j+=f[i];
}
else
{
j+=(f[i] ^ );
value+=k;
}
k>>=;
}
printf("%d\n",value);
}
return ;
}

D. Vitya and Strange Lesson Codeforces Round #430 (Div. 2)的更多相关文章

  1. Codeforces Round #430 (Div. 2) Vitya and Strange Lesson

    D.Vitya and Strange Lesson(字典树) 题意: 给一个长度为\(n\)的非负整数序列,\(m\)次操作,每次先全局异或\(x\),再查询\(mex\) \(1<=n< ...

  2. Codeforces Round #430 (Div. 2) 【A、B、C、D题】

    [感谢牛老板对D题的指点OTZ] codeforces 842 A. Kirill And The Game[暴力] 给定a的范围[l,r],b的范围[x,y],问是否存在a/b等于k.直接暴力判断即 ...

  3. 【Codeforces Round #430 (Div. 2) A C D三个题】

    ·不论难度,A,C,D自己都有收获! [A. Kirill And The Game] ·全是英文题,述大意:    给出两组区间端点:l,r,x,y和一个k.(都是正整数,保证区间不为空),询问是否 ...

  4. Codeforces Round #430 (Div. 2) D. Vitya and Strange Lesson

    因为抑或,一眼字典树 但是处理起来比较难 #include<iostream> #include<map> #include<iostream> #include& ...

  5. 【Codeforces Round #430 (Div. 2) D】Vitya and Strange Lesson

    [链接]点击打开链接 [题意] 给出一个数组,每次操作将整个数组亦或一个数x,问得到的数组的结果中的mex.mex表示为自然数中第一个没有出现过的数. [题解] 异或的效果是可以累加的,所以不用每次都 ...

  6. Vitya and Strange Lesson CodeForces - 842D 字典树+交换节点

    题意: Today at the lesson Vitya learned a very interesting function - mex. Mex of a sequence of number ...

  7. C - Ilya And The Tree Codeforces Round #430 (Div. 2)

    http://codeforces.com/contest/842/problem/C 树 dp 一个数的质因数有限,用set存储,去重 #include <cstdio> #includ ...

  8. Codeforces Round #430 (Div. 2) C. Ilya And The Tree

    地址:http://codeforces.com/contest/842/problem/C 题目: C. Ilya And The Tree time limit per test 2 second ...

  9. Codeforces Round #430 (Div. 2) - D

    题目链接:http://codeforces.com/contest/842/problem/D 题意:定义Mex为一个序列中最小的未出现的正整数,给定一个长度为n的序列,然后有m个询问,每个询问给定 ...

随机推荐

  1. python-python爬取豆果网(菜谱信息)

    #-*- coding = utf-8 -*- #获取豆果网图片 import io from bs4 import BeautifulSoup import requests #爬取菜谱的地址 ur ...

  2. jQuery的基本使用

    一.jQuery简介 jQuery是一个快速.简洁的JavaScript框架,它封装了JavaScript常用的功能代码,提供一种简便的JavaScript设计模式,优化HTML文档操作.事件处理.动 ...

  3. java语言复制数组的四种方法

    JAVA语言的下面几种数组复制方法中,哪个效率最高? B.效率:System.arraycopy > clone > Arrays.copyOf > for循环 1.System.a ...

  4. Leetcode题库——5.最长回文子串

    @author: ZZQ @software: PyCharm @file: longestPalindrome.py @time: 2018/9/18 20:06 要求:给定一个字符串 s,找到 s ...

  5. 【动态规划】POJ-3176

    一.题目 Description The cows don't use actual bowling balls when they go bowling. They each take a numb ...

  6. C/C++ 打印文件名、行号、函数名的方法

    转自:http://zhidao.baidu.com/link?url=JLCaxBAXLJVcx_8jsyJVF92E_bZjo4ONJ5Ab-HGlNBc1dfzcAyFAIygwP1qr18aa ...

  7. 关于“scrum站立会议”

    每日站立会议是SCRUM方法中的一条关键实践,整个会议可能会比较混乱粗略,但推进进度的目标却非常清晰明确,并促使团队齐心协力朝共同目标迈进. 站立会议的功能很简单,作为一个以简短为特点的项目会议,所有 ...

  8. java杂项

    简单介绍==和equals区别==是判断两个变量或实例是不是指向同一个内存空间equals是判断两个变量或实例所指向的内存空间的值是不是相同 final, finally, finalize的区别fi ...

  9. C++的继承与多态

    ◆ 概念介绍 继承:为了代码的重用,保留基类的原本结构,并新增派生类的部分,同时可能覆盖(overide)基类的某些成员. 多态:一种将不同的特殊行为和单个泛化记号相关联的能力,分为静态多态和动态多态 ...

  10. vue 组件 模板中根数据绑定需要指明路径并通信父

    <!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>T ...