zoukankan      html  css  js  c++  java
  • Codeforces D. Iahub and Xors

     题目大意:给定一个N*N的区间,1:对(x0,y0,x1,y1)每个直 都xor v;

                                                         2: 求(x0,y0,x1,y1)区间的 sum xor;

    http://codeforces.com/blog/entry/8755    

    算得上经典题:

           

     1 #include<stdio.h>
     2 #include<algorithm>
     3 #include<math.h>
     4 #include<vector>
     5 #include<string.h>
     6 #include<string>
     7 #include<set>
     8 #include<map>
     9 #include<iostream>
    10 #include<set>
    11 
    12 using namespace std;
    13 typedef long long ll;
    14 int n;
    15 
    16 ll c[2][2][1003][1003];
    17 
    18 ll query(int x,int y)
    19 {
    20  ll ret=0;
    21  for (int i=x;i>0;i-=i&-i)
    22  for (int j=y;j>0;j-=j&-j)
    23  ret^=c[x&1][y&1][i][j];
    24  return ret;
    25 }
    26 
    27 void update(int x,int y,ll v)
    28 {
    29    for (int i=x;i<=n;i+=i&-i)
    30    for (int j=y;j<=n;j+=j&-j)
    31    c[x&1][y&1][i][j]^=v;
    32 }
    33 
    34 int main()
    35 {
    36    int m,x,y,xx,yy,op;
    37    ll v;
    38    scanf("%d%d",&n,&m);
    39    while (m--)
    40    {
    41      scanf("%d%d%d%d%d",&op,&x,&y,&xx,&yy);
    42      if (op==1)
    43      {
    44        x--;
    45        y--;
    46        printf("%I64d
    ",query(x,y)^query(x,yy)^query(xx,y)^query(xx,yy));
    47      }
    48      else
    49      {
    50         scanf("%I64d",&v);
    51         xx++;
    52         yy++;
    53         update(x,y,v);
    54         update(xx,yy,v);
    55         update(x,yy,v);
    56         update(xx,y,v);
    57      }
    58    }
    59    return 0;
    60 }
  • 相关阅读:
    JavaScript 内置函数有什么?
    cursor(鼠标手型)属性
    用CSS制作箭头的方法
    CSS 的伪元素是什么?
    用CSS创建分页的实例
    CSS 按钮
    网页布局中高度塌陷的解决方法
    CSS 进度条
    DOM导航与DOM事件
    DOM 修改与DOM元素
  • 原文地址:https://www.cnblogs.com/forgot93/p/4625235.html
Copyright © 2011-2022 走看看