D. Vitya and Strange Lesson Codeforces Round #430 (Div. 2)
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)的更多相关文章
- Codeforces Round #430 (Div. 2) Vitya and Strange Lesson
D.Vitya and Strange Lesson(字典树) 题意: 给一个长度为\(n\)的非负整数序列,\(m\)次操作,每次先全局异或\(x\),再查询\(mex\) \(1<=n< ...
- 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.直接暴力判断即 ...
- 【Codeforces Round #430 (Div. 2) A C D三个题】
·不论难度,A,C,D自己都有收获! [A. Kirill And The Game] ·全是英文题,述大意: 给出两组区间端点:l,r,x,y和一个k.(都是正整数,保证区间不为空),询问是否 ...
- Codeforces Round #430 (Div. 2) D. Vitya and Strange Lesson
因为抑或,一眼字典树 但是处理起来比较难 #include<iostream> #include<map> #include<iostream> #include& ...
- 【Codeforces Round #430 (Div. 2) D】Vitya and Strange Lesson
[链接]点击打开链接 [题意] 给出一个数组,每次操作将整个数组亦或一个数x,问得到的数组的结果中的mex.mex表示为自然数中第一个没有出现过的数. [题解] 异或的效果是可以累加的,所以不用每次都 ...
- Vitya and Strange Lesson CodeForces - 842D 字典树+交换节点
题意: Today at the lesson Vitya learned a very interesting function - mex. Mex of a sequence of number ...
- C - Ilya And The Tree Codeforces Round #430 (Div. 2)
http://codeforces.com/contest/842/problem/C 树 dp 一个数的质因数有限,用set存储,去重 #include <cstdio> #includ ...
- 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 ...
- Codeforces Round #430 (Div. 2) - D
题目链接:http://codeforces.com/contest/842/problem/D 题意:定义Mex为一个序列中最小的未出现的正整数,给定一个长度为n的序列,然后有m个询问,每个询问给定 ...
随机推荐
- layui数据表格使用(一:基础篇,数据展示、分页组件、表格内嵌表单和图片)
表格展示神器之一:layui表格 前言:在写后台管理系统中使用最多的就是表格数据展示了,使用表格组件能提高大量的开发效率,目前主流的数据表格组件有bootstrap table.layui table ...
- c++文件对齐
头文件#include <iomanip> 关键词:setw(n),std::left,std::right 实例:输出一个0-4的12*12方阵,要求数字宽度为4,居左对齐,右下角输出出 ...
- 工作小应用:EXCEL查找两列重复数据
工作案例:excel存在A列.B列,需要找出B列没有A列的数据,具体做法如下(以office2007做案例): 1.点击 公式-定义名称 ,选中A列,填写名称“AAA”,选中B列,填写名称“BBB”: ...
- VS code MacOS 环境搭建
环境:MacBook Pro 参考博客 为了动手开发AI代码,我需要安装一个VS code. 开始我以为是安装visual studio呢.我装过visual studio2017. VS code是 ...
- TeamWork#3,Week5,The First Meeting of Our Team
sixsix第一次会议记录 [会议时间]2014年10月23日星期四19:00-20:00 [会议形式]小组讨论 [会议地点]5号公寓 [会议主持]高雅智 [会议记录]张志浩 会议整体流程 一.签到 ...
- Sprint计划表
Sprint会议计划 一.Sprint 需求 准备环节:小组成员利用周六周日在网上查阅Android开发的教程,练习开发一些简单的小程序,具备一定的开发能力,在电脑上搭建Android开发环境,做好 ...
- 《TCP/IP 详解 卷1:协议》第 8 章:Internet 控制报文协议
路由器是 Internet 的重要组成部分,严密监视 Internet 的操作.IP 协议未给发送失败的 IP 数据包提供一种错误处理,也没有给端系统提供直接的方法来发现错误.为了解决这一不足之处,I ...
- 基于windowsphone7的控制ppt播放
最近突然想起了一个学长的一个利用手机控制ppt播放的一个创意,并想将其在windows phone7上实现一下. 经过几天的努力已经可以控制ppt的播放,暂停,上一张,下一张了,并且电脑会将当前ppt ...
- LeetCode题解:(139) Word Break
题目说明 Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, dete ...
- 交换机、linux光衰查询
RX收光,TX发光 一.交换机 命令: display interface transceiver brief 结果: ...... HW6851 10GE1/0/15 transceiver dia ...