[题目链接]

https://codeforces.com/problemset/problem/339/D

[算法]

线段树模拟即可

时间复杂度 :O(MN)

[代码]

#include<bits/stdc++.h>
using namespace std;
#define MAXN 18
const int MAXS = << MAXN; int n , m;
int a[MAXS]; struct SegmentTree
{
struct Node
{
int l , r;
int value , d;
} Tree[MAXS << ];
inline void update(int index)
{
if (Tree[index].d == ) Tree[index].value = Tree[index << ].value | Tree[index << | ].value;
else Tree[index].value = Tree[index << ].value ^ Tree[index << | ].value;
}
inline void build(int index,int l,int r)
{
Tree[index].l = l;
Tree[index].r = r;
if (l == r)
{
Tree[index].value = a[l];
Tree[index].d = ;
return;
}
int mid = (l + r) >> ;
build(index << ,l,mid);
build(index << | ,mid + ,r);
Tree[index].d = (Tree[index << ].d + ) % ;
update(index);
}
inline void modify(int index,int pos,int val)
{
if (Tree[index].l == Tree[index].r)
{
Tree[index].value = val;
return;
}
int mid = (Tree[index].l + Tree[index].r) >> ;
if (mid >= pos) modify(index << ,pos,val);
else modify(index << | ,pos,val);
update(index);
}
inline int query()
{
return Tree[].value;
}
} T; template <typename T> inline void read(T &x)
{
T f = ; x = ;
char c = getchar();
for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
for (; isdigit(c); c = getchar()) x = (x << ) + (x << ) + c - '';
x *= f;
} int main()
{ read(n); read(m);
for (int i = ; i <= ( << n); i++) read(a[i]);
T.build(,,( << n));
while (m--)
{
int x , y;
read(x); read(y);
T.modify(,x,y);
printf("%d\n",T.query());
} return ; }

[Codeforces 339D] Xenia and Bit Operations的更多相关文章

  1. [线段树]Codeforces 339D Xenia and Bit Operations

    Xenia and Bit Operations time limit per test 2 seconds memory limit per test 256 megabytes input sta ...

  2. CodeForces 339D Xenia and Bit Operations (线段树)

    题意:给定 2的 n 次方个数,对这些数两个两个的进行或运算,然后会减少一半的数,然后再进行异或运算,又少了一半,然后再进行或运算,再进行异或,不断重复,到最后只剩下一个数,要输出这个数,然后有 m ...

  3. codeforces 339C Xenia and Bit Operations(线段树水题)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Xenia and Bit Operations Xenia the beginn ...

  4. Xenia and Bit Operations CodeForces - 339D

    Xenia and Bit Operations CodeForces - 339D Xenia the beginner programmer has a sequence a, consistin ...

  5. [codeforces 339]D. Xenia and Bit Operations

    [codeforces 339]D. Xenia and Bit Operations 试题描述 Xenia the beginner programmer has a sequence a, con ...

  6. 线段树 Codeforces Round #197 (Div. 2) D. Xenia and Bit Operations

    题目传送门 /* 线段树的单点更新:有一个交叉更新,若rank=1,or:rank=0,xor 详细解释:http://www.xuebuyuan.com/1154895.html */ #inclu ...

  7. Codeforces Round #197 (Div. 2) D. Xenia and Bit Operations

    D. Xenia and Bit Operations time limit per test 2 seconds memory limit per test 256 megabytes input ...

  8. cf339d Xenia and Bit Operations

    Xenia and Bit Operations Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & ...

  9. Xenia and Bit Operations(线段树单点更新)

    Xenia and Bit Operations time limit per test 2 seconds memory limit per test 256 megabytes input sta ...

随机推荐

  1. [Python3网络爬虫开发实战] 2.2-网页基础

    用浏览器访问网站时,页面各不相同,你有没有想过它为何会呈现这个样子呢?本节中,我们就来了解一下网页的基本组成.结构和节点等内容. 1. 网页的组成 网页可以分为三大部分——HTML.CSS和JavaS ...

  2. MySQL 快速入门教程

    转:MySQL快速 入门教程 目录 一.MySQL的相关概念介绍 二.Windows下MySQL的配置 配置步骤 MySQL服务的启动.停止与卸载 三.MySQL脚本的基本组成 四.MySQL中的数据 ...

  3. build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing

    maven test项目时遇到一下错误 Some problems were encountered while building the effective model for cn.temptat ...

  4. Jquery validate自定义验证

    http://www.runoob.com/jquery/jquery-plugin-validate.html addMethod(name,method,message)方法 参数 name 是添 ...

  5. 牛客练习赛29 B 列队

    [题解] 把某一行或某一列有4个1的都统计出来,然后首尾接上尽量长的,注意首尾不能选上同一个矩阵,要维护前缀.后缀1最大值和次大值. 还要注意维护矩阵内连续1的长度,因为可能有 0 0 0 0 这种情 ...

  6. java 几种拼接字符串的效率问题

    拼接字符串,大致有3个class可以用,他们是String, StringBuffer,StringBuilder, StringBuilder是1.5中来代替StringBuffer的.检验方法如下 ...

  7. java程序验证用户名密码和验证码登录的小例子

    package Study02; import java.util.Random; import java.util.Scanner; public class test { static Strin ...

  8. MTK平台 GPU 相关知识

    一.什么是Render script,以及mtk平台GPU support情况 [DESCRIPTION] 1.什么是RenderScript ? 2.RenderScript 干什么? 3.MTK平 ...

  9. HDU 5876 补图 单源 最短路

    ---恢复内容开始--- Sparse Graph Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (J ...

  10. .net 程序集保护与破解

    一.保护方法(强签名.混淆.加壳) 强名称是由程序集的标识加上公钥和数字签名组成的.其中,程序集的标识包括简单文本名称.版本号.区域性信息(如果提供的话).语言文化信息.处理器架构信息.强名称是使用相 ...