纠结的二维数组 Matrix

来源:互联网 发布:泡妞宝鉴天地知我心txt 编辑:程序博客网 时间:2024/06/05 02:55

其实对于Matrix 我很喜欢看的一部电影《黑客帝国》...兴致勃勃的去做,哎~可惜却是我最痛恨的英文...

蛋疼...黑客帝国Matrix VS zion 确实很不错...我弄了个电子版程序介绍,不错的哦~有兴趣的朋友可以去我空间日志去看看。

http://user.qzone.qq.com/504281906/infocenter

废话不多说,哎~最近逻辑混乱了,说话打字颠三倒四的...

#include <cstdio>#include <cstdlib>#include <cstring>#include <iostream>#include <cmath>#include <algorithm>using namespace std;int n,m,ans;int a[1010][1010];void sum(int x,int y){while (x<=n){int y1=y;while (y1<=n){a[x][y1]^=1;y1+=(y1 & -y1);}x+=(x & -x);}}void update(int x,int y,int x1,int y1){sum(x,y);sum(x1+1,y);sum(x,y1+1);sum(x1+1,y1+1);}void answer(int x,int y){ans=0;while (x>0){int y1=y;while (y1>0){ans= (ans+a[x][y1])&1;y1-=(y1 & -y1);}x-=(x & -x);}ans&=1;printf("%d\n",ans);}int main(){int T;scanf("%d",&T);while (T--){scanf("%d%d",&n,&m);memset(a,0,sizeof(a)); while (m--){char c[2];scanf("%s",&c);if (c[0]=='C'){int x,x1,y,y1;scanf("%d%d%d%d",&x,&y,&x1,&y1);getchar();update(x,y,x1,y1);}else {int x,y;scanf("%d%d",&x,&y);getchar();answer(x,y);}}cout<<endl;}return 0;}


 

 

  

原创粉丝点击