F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

ZCC Loves COT

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 407    Accepted Submission(s): 138


Problem Description
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).
 

Input
First line: three positive integer N, M, Q.(N¡Ü100, M¡Ü100000, Q¡Ü100000)
Then followed M lines, each line contains four integers Mxi, Myi, Mzi, Mai, which describe an operation.
Then followed Q lines, each line contains four integers Qxi, Qyi, Qzi, Qai, which describe a query.
 

Output
For every query, output a line with one integer, the answer to the query.
 

Sample Input
2 1 2 1 1 1 2 1 1 1 2 2 1 1 1
 

Sample Output
4 1
 

Hint
It is guaranteed, for every sT(x, y, z, a): 1¡Üz¡Üy¡Üx¡Üx+a-1¡ÜN.
 

Author
Õòº£ÖÐѧ
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-12 11:37:49, Gzip enabled