HDU 3584 Cube (three-bit tree-like array)

Source: Internet
Author: User

Cube

Time limit:2000/1000 MS (java/others) Memory limit:131072/65536 K (java/others)
Total submission (s): 1949 Accepted Submission (s): 1013


Problem Descriptiongiven an n*n*n cube A, whose elements is either 0 or 1. A[i, J, K] means the number in the I-th row, j-th column and k-th layer. Initially we have A[i, J, K] = 0 (1 <= i, J, K <= N).
We define operations, 1: ' Not ' operation that we change the A[i, J, k]=! A[i, J, K]. That's means we change A[i, J, K] from 0->1,or 1->0. (X1&LT;=I&LT;=X2,Y1&LT;=J&LT;=Y2,Z1&LT;=K&LT;=Z2).
0: "Query" Operation we want to get the value of A[i, J, K].

Inputmulti-cases.
First line contains N and M, m lines follow indicating the operation below.
Each operation contains an X, the type of operation. 1: "not" operation and 0: "Query" operation.
If X is 1, following x1, Y1, Z1, x2, Y2, Z2.
If x is 0, following x, Y, Z.

Outputfor each query output a[x, Y, z] on one line. (1<=n<=100 sum of M <=10000)

Sample INPUT2 51 1 1 1 1 1 10 1 1 11 1 1 1 2 2 20 1 1 10 2 2 2

Sample Output101

Authoralpc32

Source acm-icpc multi-university Training Contest (--host by Nudt)

Recommendzhouzeyong | We have carefully selected several similar problems for you:3450 1541 1394 2492 3743
/*test instructions is too vague, two operations 0: a single point of query, the number of this point is how much 1: the number of a certain interval is reversed; just need to maintain the prefix of the number of reversals and the compiler is out of order, the macro definition does not work, call the function*/#include<iostream>#include<stdio.h>#include<string.h>#defineN 110//#define LOWBIT (x) x& (-X)using namespacestd;intn,m;intC[n][n][n];intLowbit (intx) {    returnx& (-x);}voidUpdateintXintYintZintval) {     while(x<=N) {intj=y;  while(j<=N) {intk=Z;  while(k<=N) {c[x][j][k]+=Val; K+=Lowbit (k); } J+=Lowbit (j); } x+=lowbit (x); }}intGetsum (intXintYintz) {    ints=0;  while(x>0)    {        intj=y;  while(j>0)        {            intk=Z;  while(k>0) {s+=C[x][j][k]; K-=Lowbit (k); } J-=Lowbit (j); } x-=lowbit (x); }    returns;}intMain () {//freopen ("C:\\users\\acer\\desktop\\in.txt", "R", stdin);     while(SCANF ("%d%d", &n,&m)! =EOF) {memset (c,0,sizeofc); intop,x1,y1,z1,x2,y2,z2;  while(m--) {scanf ("%d",&op); if(OP) {scanf ("%d%d%d%d%d%d",&x1,&y1,&z1,&x2,&y2,&z2); Update (x2+1, y2+1, z2+1,1); Update (x1, y2+1, z2+1,1); Update (x2+1, Y1, z2+1,1); Update (x2+1, y2+1, Z1,1); Update (x1, y1, Z2+1,1); Update (x2+1, Y1, Z1,1); Update (x1, y2+1, Z1,1); Update (x1, y1, Z1,1); }            Else{scanf ("%d%d%d",&x1,&y1,&Z1); //cout<< "Getsum (X1,Y1,Z1) =" <<getsum (x1,y1,z1) <<endl;printf"%d\n", Getsum (X1,Y1,Z1) &1); }        }    }    return 0;}

HDU 3584 Cube (three-bit tree-like array)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.