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

Source: Internet
Author: User

Topic Portal

1 /*2 single point update for segment tree: There is a cross-update, if Rank=1,or;rank=0,xor3 Detailed Explanation:http://www.xuebuyuan.com/1154895.html4 */5#include <cstdio>6#include <iostream>7#include <algorithm>8#include <cstring>9#include <string>Ten#include <cmath> One#include <Set> A#include <map> - using namespacestd; - #defineLson L, Mid, RT << 1 the #defineRson mid+1, R, RT << 1 | 1 -  - Const intMAXN =1<< -|1; - Const intINF =0x3f3f3f3f; + structNODE - { +     intV, MX, MN, sum; A     intrank; at}NODE[MAXN <<2]; -  - voidPUSH_UP (intRT) - { -     if(node[rt<<1].rank = =1) -     { inNode[rt].rank =0; -NODE[RT].V = node[rt<<1].V | node[rt<<1|1].v; to     } +     Else -     { theNode[rt].rank =1; *NODE[RT].V = node[rt<<1].v ^ node[rt<<1|1].v; $     }Panax Notoginseng } -  the  + voidBuildintLintRintRT) A { the     if(L = =R) +     { -scanf ("%d", &node[rt].v); $Node[rt].rank =1; $         return ; -     } -     intMid = (L + r) >>1; the build (Lson); - build (Rson);Wuyi  the push_up (RT); - } Wu  - voidUpdata (intPintBintLintRintRT) About { $     if(L = =R) -     { -NODE[RT].V =b; -         return ; A     } +     intMid = (L + r) >>1; the     if(P <=mid) Updata (p, B, Lson); -     ElseUpdata (p, B, Rson); $  the push_up (RT); the } the  the  - intMainvoid)//codeforces Round #197 (Div. 2) D. Xenia and Bit Operations in { the     //freopen ("h.in", "R", stdin); the  About     intN, M; thescanf ("%d%d", &n, &m); theBuild (1,1<<n,1); the  +     intp, b; -      for(intI=1; i<=m; ++i) the     {Bayiscanf ("%d%d", &p, &b); theUpdata (p, B,1,1<<n,1); theprintf ("%d\n", node[1].v); -     } -  the     return 0; the}

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.