首页 > 代码库 > 2016 ACM/ICPC Asia Regional Shenyang Online

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             else59             {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

2016 ACM/ICPC Asia Regional Shenyang Online