Time Limit: 2000/1000 MS (Java/Others)

Memory Limit: 262144/262144 K (Java/Others)

After solves all problem of the series COT(count on a tree), ZCC feels bored and came up with a new COT problem, where letter T stands of Tetrahedron.

In this problem, Tetrahedron is define as a set of point:

T(n) = {(x, y, z) | 1≤z≤y≤x≤n}

Imagine T(n) is divided into n layers, the k-th layer contains k rows, of which the l-th row contains l points.

Moreover, we define sub-Tetrahedron a set of point, too:

sT(x, y, z, a) = {(x+i, y+j, z+k) | 0≤k≤j≤i＜a}

First of all, you are given a Tetrahedron T(N), every point of T(N) has a value of 0.

Then, you should deal with M operation (Mxi, Myi, Mzi, Mai), means you should add 1 to every point’s value if it belongs to sT(Mxi, Myi, Mzi, Mai).

Then, you should deal with Q queries (Qxi, Qyi, Qzi, Qai), you should output the sum of values of points in sT(Qxi, Qyi, Qzi, Qai).

In this problem, Tetrahedron is define as a set of point:

T(n) = {(x, y, z) | 1≤z≤y≤x≤n}

Imagine T(n) is divided into n layers, the k-th layer contains k rows, of which the l-th row contains l points.

Moreover, we define sub-Tetrahedron a set of point, too:

sT(x, y, z, a) = {(x+i, y+j, z+k) | 0≤k≤j≤i＜a}

First of all, you are given a Tetrahedron T(N), every point of T(N) has a value of 0.

Then, you should deal with M operation (Mxi, Myi, Mzi, Mai), means you should add 1 to every point’s value if it belongs to sT(Mxi, Myi, Mzi, Mai).

Then, you should deal with Q queries (Qxi, Qyi, Qzi, Qai), you should output the sum of values of points in sT(Qxi, Qyi, Qzi, Qai).

提交代码