#P11372. K-Dimensional Inspection
K-Dimensional Inspection
K-Dimensional Inspection
In this problem, you are given a k-dimensional world which can be regarded as an nk grid with coordinates in each dimension ranging from 1 to n. There are three types of entities in the grid:
- OIers: There are m OIers located at positions \( (a_{i,1},a_{i,2},\cdots,a_{i,k}) \) (1 \le i \le m). They are all goofing off.
- Obstacles: There are x obstacles located at positions \( (b_{i,1},b_{i,2},\cdots,b_{i,k}) \) (1 \le i \le x).
- Coaches: There are y coaches located at positions \( (c_{i,1},c_{i,2},\cdots,c_{i,k}) \) (1 \le i \le y). Coaches want to catch the OIers who are slacking off.
A coach can detect an OIer if and only if the coach and the OIer share exactly \( k-1 \) identical coordinates and differ in exactly one coordinate. Moreover, if you consider the line segment connecting the coach and the OIer (which lies along the axis where their coordinates differ), there must be no other entity (obstacle, OIer, or coach) on any point strictly between them.
Your task is to determine, for each coach, how many OIers can be detected.
Note: All formulas are presented in LaTeX format.
inputFormat
The first line contains five integers: \( n, k, m, x, y \) where \( n \) is the size of each grid dimension, and \( k \) is the number of dimensions.
The next \( m \) lines each contain \( k \) integers: \( a_{i,1}, a_{i,2}, \dots, a_{i,k} \) representing the coordinates of the OIers.
The following \( x \) lines each contain \( k \) integers: \( b_{i,1}, b_{i,2}, \dots, b_{i,k} \) representing the coordinates of obstacles.
The last \( y \) lines each contain \( k \) integers: \( c_{i,1}, c_{i,2}, \dots, c_{i,k} \) representing the coordinates of the coaches.
outputFormat
Output \( y \) integers. The \( i\)-th integer should represent the number of OIers that the \( i\)-th coach can detect. The outputs for multiple coaches can be separated by spaces or newlines.
sample
5 2 2 1 2
2 3
4 3
3 3
1 3
4 5
1
1
</p>