概述
MiYu原创, 转帖请注明 : 转载自 ______________白白の屋
题目描述:
Cube
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)Total Submission(s): 495 Accepted Submission(s): 226
Problem Description
Given an N*N*N cube A, whose elements are 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 two operations, 1: “Not” operation that we change the A[i, j, k]=!A[i, j, k]. that means we change A[i, j, k] from 0->1,or 1->0. (x1<=i<=x2,y1<=j<=y2,z1<=k<=z2).
0: “Query” operation we want to get the value of A[i, j, k].
We define two operations, 1: “Not” operation that we change the A[i, j, k]=!A[i, j, k]. that means we change A[i, j, k] from 0->1,or 1->0. (x1<=i<=x2,y1<=j<=y2,z1<=k<=z2).
0: “Query” operation we want to get the value of A[i, j, k].
Input
Multi-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.
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.
Output
For each query output A[x, y, z] in one line. (1<=n<=100 sum of m <=10000)
Sample Input
2 5 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 2 2 2 0 1 1 1 0 2 2 2
Sample Output
1 0 1
题目分析 :
更新区间, 查询一个点, 三维线段树 直接无视.........数据不是很强, 所以 直接暴力就可以过, 过完发现自己的时间 在700MS 左右, 看了下rank,
小A 榜首..... 时间竟然才62MS....果然还是要用三维树状数组来加速啊 . 不过一直没理解 用 树状数组 解决这题的思路, 今早上终于明白了.
画个图先 :
好了 , 看代码:
树状数组代码 :
/*
std scan_dnum in IsN ingetcharinEOFininin ingetcharin IsNnum numiningetcharinin numnuminIsN numnum MAXN matMAXNMAXNMAXN lowMAXN i j k setLow i i MAXN i lowi i i modify x y z i x i MAXN i lowi j y j MAXN j lowj k z k MAXN k lowk matijk query x y z sum i x i i lowi j y j j lowj k z k k lowk sum matijk sum setLow N M scan_d N scan_d M memset mat mat M x1y1z1x2y2z2 s scan_d s s scan_d x1 scan_d y1 scan_d z1 scan_d x2 scan_d y2 scan_d z2 modify x1y1z1 modify x1y1z2 modify x2y1z1 modify x2y1z2 modify x1y2z1 modify x2y2z1 modify x2y2z2 modify x1y2z2 scan_d x1 scan_d y1 scan_d z1 printf query x1y1z1
暴力代码 :
std node x1 x2 y1 y2 z1 z2cube N M x y z scanfNM EOF cnt M ask scanfask ask scanfcubecntx1cubecnty1cubecntz1cubecntx2cubecnty2cubecntz2 cnt scanfxyz count i i cnt i cubeix1 x x cubeix2 cubeiy1 y y cubeiy2 cubeiz1 z z cubeiz2 count puts count
转载于:https://www.cnblogs.com/MiYu/archive/2010/11/14/1876848.html
最后
以上就是任性楼房为你收集整理的HDU 3584 HDOJ 3584 Cube ACM 3584 IN HDUCube的全部内容,希望文章能够帮你解决HDU 3584 HDOJ 3584 Cube ACM 3584 IN HDUCube所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复