[题目链接]

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网络爬虫开发实战] 1.2.2-Selenium的安装

    Selenium是一个自动化测试工具,利用它我们可以驱动浏览器执行特定的动作,如点击.下拉等操作.对于一些JavaScript渲染的页面来说,这种抓取方式非常有效.下面我们来看看Selenium的安装 ...

  2. DB2隔离级别

    四.隔离级别与锁 数据库是利用锁和隔离级别来共同处理数据库的并发的.DB2数据库用来尝试实施并发性的方法之一是通过使用隔离级别,它决定在第一个事务访问数据时,如何对其他事务锁定或隔离该事务所使用的数据 ...

  3. flash-热风焊盘的制作

    计算部分: 热风焊盘的内径(ID)等于钻孔直径+20mil, 外径(OD)等于Anti-pad的直径,通常是比焊盘的直径大20mil. 开口宽度等于(OD-ID)/2+10mil,保留整数位. 如果焊 ...

  4. 【计算几何+极角排序+爆ll】E. Convex

    https://www.bnuoj.com/v3/contest_show.php?cid=9147#problem/E [题意] 给定n个点的坐标,可以选择其中的四个点构造凸四边形,问最多能构造多少 ...

  5. bzoj 2588 Spoj 10628. Count on a tree (可持久化线段树)

    Spoj 10628. Count on a tree Time Limit: 12 Sec  Memory Limit: 128 MBSubmit: 7669  Solved: 1894[Submi ...

  6. [NOIP2008] 提高组 洛谷P1125 笨小猴

    题目描述 笨小猴的词汇量很小,所以每次做英语选择题的时候都很头疼.但是他找到了一种方法,经试验证明,用这种方法去选择选项的时候选对的几率非常大! 这种方法的具体描述如下:假设maxn是单词中出现次数最 ...

  7. ELK pipeline

    https://www.felayman.com/articles/2017/11/24/1511527532643.html?utm_medium=hao.caibaojian.com&ut ...

  8. springboot 子模块访问不到对应的页面

    出现如下错误 解决方案 working directory:没有$MODULE_DIR$该选项,自己输入即可. 完成以上操作就可以正常访问页面了.

  9. Ubuntu 16.04安装WinRAR/7-Zip(基于CrossOver)

    基于CrossOver的WinRAR/7-Zip有如下缺点: 1.不能像Windows那样右键菜单解压 可以解决的问题: 1.可以使用提供的浏览工具进行文件选择再解压,只是在操作上多一步. 2.类似百 ...

  10. dstat用法;利用awk求dstat所有列每列的和;linux系统监控

    安装:yum install -y dstat dstat命令是一个用来替换vmstat.iostat.netstat.nfsstat和ifstat这些命令的工具,是一个全能系统信息统计工具.与sys ...