Cube pile
InterviewTime limit1sMemory limit1024 MB
Count the cubes whose six face-adjacent positions all contain cubes in an N by N by N grid.
- Level
Easy2 of 10
- Topics
- Implementation, Array
- Solved
- No attempts yet
Problem
A cube space of size is given. A coordinate in this space is a triple of integers satisfying .
There are cubes in the space, and each cube occupies exactly one coordinate. No two cubes share a coordinate. Count the cubes that satisfy the following condition.
- If a cube exists at , then cubes also exist at all 6 positions .
Input
The first line contains two integers and .
Each of the next lines contains three integers , , and . This means a cube exists at .
Output
Print the answer to the problem.
Constraints
- No coordinate is given more than once