2016 ACM/ICPC Asia Regional Shenyang Online

1001 Resident Evil

寻思好久为何不用无脑线段树呀好像内存不够哦。

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cstring>
 4 using namespace std;
 5 const int maxn = 3e3 + 10;
 6 typedef long long LL;
 7 
 8 // BIT - 2D
 9 LL c[2][2][maxn][maxn];
10 int lowbit(int s)
11 {
12     return s & (-s);
13 }
14 void modify(int x, int y, LL v)
15 {
16     for(int i = x; i < maxn; i += lowbit(i))
17         for(int j = y; j < maxn; j += lowbit(j))
18             c[x&1][y&1][i][j] ^= v;
19     return;
20 }
21 LL query(int x, int y)
22 {
23     LL ret = 0;
24     for(int i = x; i > 0; i -= lowbit(i))
25         for(int j = y; j > 0; j -= lowbit(j))
26             ret ^= c[x&1][y&1][i][j];
27     return ret;
28 }
29 
30 int main(void)
31 {
32     int n, m;
33     while(~scanf("%d %d", &n, &m))
34     {
35         memset(c, 0, sizeof(c));
36         char op[11];
37         int x1, y1, x2, y2;
38         while(m--)
39         {
40             scanf("%s %d %d %d %d", op, &x1, &y1, &x2, &y2);
41             if(op[0] == 'P')
42             {
43                 int k;
44                 scanf("%d", &k);
45                 for(int i = 1; i <= k; i++)
46                 {
47                     int a, b;
48                     scanf("%d %d", &a, &b);
49                     if(b & 1)
50                     {
51                         modify(x1, y1, 1LL << a);
52                         modify(x1, y2 + 1, 1LL << a);
53                         modify(x2 + 1, y1, 1LL << a);
54                         modify(x2 + 1, y2 + 1, 1LL << a);
55                     }
56                 }
57             }
58             else
59             {
60                 LL ans = query(x2, y2) ^ query(x1 - 1, y2) ^ query(x2, y1 - 1) ^ query(x1 - 1, y1 - 1);
61                 for(int i = 1; i <= 50; i++)
62                     printf("%d ", (1LL << i) & ans ? 2 : 1);
63                 puts("");
64             }
65         }
66     }
67     return 0;
68 }
Aguin

 

1002 List wants to travel

1003 hannnnah_j’s Biological Test

1004 Mathematician QSC

1005 Running King

1006 The Game

1007 odd-even number

1008 oasis in desert

1009 QSC and Master

1010 Count primes

转载于:https://www.cnblogs.com/Aguin/p/5890716.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值