hdu 5892 List wants to travel 2016ACM/ICPC沈阳赛区网络赛1001
来源:互联网 发布:淘宝上卖高仿鞋的店 编辑:程序博客网 时间:2024/05/22 03:37
Problem Description
The Umbrella Company has developed a new biochemical virus secretly. Lyon, a staff of the company, happened to find out the conspiracy and his company is now stopping him from discovering further evidence by releasing biochemical monster in his city (don’t ask me why the company is using this weird method).
The city can be described as an n*n grids. The Umbrella Company has 50 kinds of biochemical monster in total. The company will specify the type, quantity of biochemical monster and the rectangle area to put monster. For example, if the specified rectangle area has upper left corner (1, 1) and bottom right corner of (3, 3), and the company wishes to put 3 of A monster, 2 of B monster and 1 of C monster in it, then 3 of A monster, 2 of B monster and 1 of C monster is added to each and every grid inside the area.
However, Lyon risk his life of finding evidence by searching certain rectangle area. By doing this, all monsters inside the area would gather to him. He has two way of dealing with monster. If the number of a certain kind of monster is even, then he would choose to hide, otherwise withdraw.
The city can be described as an n*n grids. The Umbrella Company has 50 kinds of biochemical monster in total. The company will specify the type, quantity of biochemical monster and the rectangle area to put monster. For example, if the specified rectangle area has upper left corner (1, 1) and bottom right corner of (3, 3), and the company wishes to put 3 of A monster, 2 of B monster and 1 of C monster in it, then 3 of A monster, 2 of B monster and 1 of C monster is added to each and every grid inside the area.
However, Lyon risk his life of finding evidence by searching certain rectangle area. By doing this, all monsters inside the area would gather to him. He has two way of dealing with monster. If the number of a certain kind of monster is even, then he would choose to hide, otherwise withdraw.
Input
A line containing n and m (1<=n<=3000 1<=m<=100000). Representing the size of the city and the number of operations.
Then m lines of operation and there are only two kinds of operation.
Letter ‘P’ means to release monster, followed by 4 integers x1, y1, x2, y2 (1<=x1, y1, x2, y2<=n) , describing the upper left corner and bottom right corner of the area. Then an integer K(1<=K<=50), meaning there will be k pair of number (A, B) given next. A (1<=A<=50) indicates the kind of the monster and B (1<=b<=100000) indicates the number of this kind being added to this area.
Letter ‘Q’ represents the query operation, followed by 4 integers x1, y1, x2, y2 (1<=x1, y1, x2, y2<=n), describing the upper left corner and bottom right corner of the area.
Then m lines of operation and there are only two kinds of operation.
Letter ‘P’ means to release monster, followed by 4 integers x1, y1, x2, y2 (1<=x1, y1, x2, y2<=n) , describing the upper left corner and bottom right corner of the area. Then an integer K(1<=K<=50), meaning there will be k pair of number (A, B) given next. A (1<=A<=50) indicates the kind of the monster and B (1<=b<=100000) indicates the number of this kind being added to this area.
Letter ‘Q’ represents the query operation, followed by 4 integers x1, y1, x2, y2 (1<=x1, y1, x2, y2<=n), describing the upper left corner and bottom right corner of the area.
Output
For every ‘Q’ operation. Print 50 number in a line, meaning the kind of action he would take for different kinds of monsters. 1 represents hiding and 2 represents withdrawing.
Sample Input
2 2P 1 1 2 2 1 1 1 Q 1 1 1 1
Sample Output
2 1 1 1 1 1 ........1 (one '2' and forty-nine '1')
四个树状数组维护。。具体看传送门
http://www.cnblogs.com/Kurokey/p/5887157.html
调了一个晚上各种错误。。
#include<map>#include<cmath>#include<queue>#include<vector>#include<cstdio>#include<string>#include<cstring>#include<iostream>#include<algorithm>using namespace std;int n,m;long long tr[2][2][3002][3002];inline int lowbit(int x){return x&(-x);}inline void add(int x,int y,long long xx){int i,j;for(i=x;i<=n;i+=lowbit(i))for(j=y;j<=n;j+=lowbit(j))tr[x&1][y&1][i][j]^=xx;}inline long long ask(int x,int y){int i,j;long long ans=0;for(i=x;i>=1;i-=lowbit(i))for(j=y;j>=1;j-=lowbit(j))ans^=tr[x&1][y&1][i][j];return ans;}int main(){while(scanf("%d%d",&n,&m)!=EOF){memset(tr,0,sizeof(tr));int i,j,x1,y1,x2,y2,k,x,y;string xx;for(i=1;i<=m;i++){cin>>xx;if(xx=="P"){scanf("%d%d%d%d",&x1,&y1,&x2,&y2);scanf("%d",&k);long long del=0;for(j=1;j<=k;j++){scanf("%d%d",&x,&y);if(y%2==1)del^=((long long)1<<(long long)(x-1));}add(x1,y1,del);add(x1,y2+1,del);add(x2+1,y1,del);add(x2+1,y2+1,del);}else{scanf("%d%d%d%d",&x1,&y1,&x2,&y2); long long ans1=ask(x1-1,y1-1)^ask(x1-1,y2)^ask(x2,y1-1)^ask(x2,y2); for(j=1;j<=50;j++) { if((ans1&((long long)1<<(long long)(j-1)))) printf("2 "); else printf("1 "); } printf("\n");}}}return 0;}
0 0
- hdu 5892 List wants to travel 2016ACM/ICPC沈阳赛区网络赛1001
- hdu 5893 List wants to travel 2016ACM/ICPC沈阳赛区网络赛1002
- 2016ACM/ICPC Shengyang Online-1002 List wants to travel
- 2016 ACM/ICPC Asia Regional Shenyang Online HDU 5893 List wants to travel
- 2016 ACM/ICPC Reginal Shengyang hdu 5893 List wants to travel(树链剖分 线段树区间更新真蛋疼)★
- HDU5893 List wants to travel (树链剖分 + 线段树) 2016 ACM/ICPC Asia Regional Shenyang Online
- hdu 5898 odd-even number 2016ACM/ICPC沈阳赛区网络赛1007
- hdu 5898 odd even number(acm/icpc沈阳赛区网络赛,数位DP)
- 2017 ACM-ICPC 亚洲区(沈阳赛区)网络赛
- Hdu-5893 List wants to travel(树链剖分)
- [树链剖分] HDU 5893 List wants to travel
- HDU 5893 List wants to travel
- HDU 5893 List wants to travel 树链剖分
- hdu 5893 List wants to travel
- HDU 5893 List wants to travel
- List wants to travel
- hdu 5950 2016ACM/ICPC沈阳赛区现场赛C题【矩阵快速幂】
- hdu 5956 The Elder 2016ACM/ICPC沈阳赛区现场赛I
- iOS 隐藏status bar(状态栏/电池条)的详细研究
- 2017今日头条测试开发
- Centos下 jsoncpp使用详解
- 顺序表应用7:最大子段和之分治递归法
- 顺序表实现一元稀疏多项式
- hdu 5892 List wants to travel 2016ACM/ICPC沈阳赛区网络赛1001
- 采用THree.js为三角网格的每一个面填充颜色
- BZOJ 2006 && NOI 2010 优先队列
- Android Service完全解析,关于服务你所需知道的一切(下)
- 数据结构实验之栈六:下一较大值(二)
- Javascript中事件委托(delegate)是如何运行的
- 第4周 项目3 -- 单链表应用(3)
- How to solve “Plugin execution not covered by lifecycle configuration” for Spring Data Maven Builds
- poj3070 Fibonacci 数论专题