In the event of technical difficulties with Szkopuł, please contact us via email at [email protected].
If you are familiar with IRC chat, the support team is also reachable on PIRC network (irc.pirc.pl
) in #szkopul
channel. If you are not, just use email.
Please do not ask us things like "how to solve task XYZ?".
Please remember that the support team has to sleep sometimes or go to work in real life.
Byteasar is going to buy an industrial plot.
His fortune is estimated at bythalers and this is exactly the amount
Byteasar would like to spend on the parcel.
Finding a parcel worth exactly
bythalers, however, is not an easy task.
For this reason Byteasar is ready to buy a more expensive plot.
He considers taking out a loan. The Byteotian Credit Bank will grant him
a loan of up to
bythalers. Thus, Byteasar can spend no more than
bythalers on the parcel and he would like to spend no less than
bythalers.
The area in which Byteasar wants to buy his parcel is a square with side
length of metres.
The current landlords have set up various prices per square metre.
Byteasar has spoken to each one of them and has then prepared a price map
of the area.
The map depicts the price of every metre by metre square. Clearly, there
are
such squares.
Now is the time to find the dream parcel.
It has to be rectangular and consist of whole unit squares.
Byteasar has already started looking for the plot on the map,
but after many hours he was still unable to find a suitable one.
Be a chap and help him!
Write a programme that:
The first line of the standard input contains two integers, and
,
separated by a single space,
,
.
Each of the following
lines contains
non-negative integers,
separated by single spaces.
number in the line no.
denotes the price of unit square
with coordinates
.
The price of one square metre does not exceed
bythalers.
If no plot with price in the interval exists,
your programme should output exactly one line with word NIE
(NO in Polish).
Otherwise it should print out one line with four positive integers
separated by single spaces and denoting the rectangle's
coordinates.
denotes the upper left rectangle corner, while
the lower right corner.
Then it consists of the squares:
.
The sum
of prices of the squares forming up this rectangle should
satisfy the inequality
.
If more than one rectangular parcel satisfies this condition, pick one
arbitrarily.
For the input data:
4 3 1 1 1 1 9 1 1 1 1
the correct result is:
NIE
and for the input data:
8 4 1 2 1 3 25 1 2 1 4 20 3 3 3 30 12 2
the correct result is:
2 1 4 2
Task author: Marcin Kubica.