#P4791. Worm Worries

    ID: 18035 Type: Default 1000ms 256MiB

Worm Worries

Worm Worries

This problem is translated from BalticOI 2018 Day1 "Worm Worries".

You are given a three-dimensional space of size \(N \times M \times K\). Each point in this space has a positive integer parameter denoted by \(H[x,y,z]\) where \(1 \le x \le N\), \(1 \le y \le M\), \(1 \le z \le K\) and \(H[x,y,z] \le 10^9\). A point outside the first octant (i.e. any coordinate out of bounds) is considered to have a parameter value of 0.

You are allowed to make at most \(Q\) queries. Your goal is to find a point \((x,y,z)\) such that:

[ H[x,y,z] \geq \max\Bigl( H[x+1,y,z],; H[x-1,y,z],; H[x,y+1,z],; H[x,y-1,z],; H[x,y,z+1],; H[x,y,z-1] \Bigr). ]

Note: This is an interactive problem. In our offline version, the full grid is given as input.

inputFormat

The first line of input contains four integers \(N\), \(M\), \(K\), and \(Q\), representing the dimensions of the space and the maximum number of queries allowed.

The following line contains \(N \times M \times K\) positive integers. These represent the values of \(H[x,y,z]\) in the following order: for \(x = 1\) to \(N\), for each \(y = 1\) to \(M\), and for each \(z = 1\) to \(K\), the corresponding value is given.

outputFormat

Output three integers \(x\), \(y\), \(z\) separated by spaces, representing a point that satisfies the property:

[ H[x,y,z] \geq \max\Bigl( H[x+1,y,z],; H[x-1,y,z],; H[x,y+1,z],; H[x,y-1,z],; H[x,y,z+1],; H[x,y,z-1] \Bigr). ]

If more than one valid point exists, output any of them.

sample

2 2 2 10
1 2 3 4 5 6 7 8
2 2 2