In the event of technical difficulties with Szkopuł, please contact us via email at [email protected].
If you would like to talk about tasks, solutions or technical problems, please visit our Discord servers. They are moderated by the community, but members of the support team are also active there.
A scourge of frogs destroying all the crop has started in Byteotia. A farmer named Byteasar has decided to fight the vermin with peculiar "scarefrogs", that he has set up at certain points of his field. While moving from one place to another, every frog tries to keep as far of them as possible, i.e. maximizes the distance to the closest scarefrog.
The field that belongs to Byteasar has rectangular shape. The frogs leap in directions parallel to the field's sides and their leaps are unitary (of length ). The scarefrogs-distance, for a given frog's route, is the minimum of all distances from all scarefrogs at all inter-leap-points of the route.
Byteasar already knows the most common starting and destination points of the frogs' routes, therefore he experiments with various deployments of the scarefrogs. He asks you for help, namely he would like you to write a programme that calculates the maximum (over all routes) scarefrogs-distance for a given deployment of scarefrogs - which we call in short the frogshold distance.
Write a programme that:
The first line of the input contains two integers: and separated by a single space - the breadth and length of the field (). The second line of the input contains four integers: , , and separated by single spaces; is the initial position of the frog, is the target (final) position of the frog (, ). The third line of the standard input contains one integer - the number of scarefrogs deployed on the field (). The following lines contain the coordinates of subsequent scarefrogs. The line no. for contains two integers and separated by a single space - these are the coordinates of the ith scarefrog (, ). No two scarefrogs occupy the same position and none of them is at the point nor .
In the first and only line of the standard output one integer should be written, namely the square of the frogshold distance. If the frog cannot avoid leaping directly on some scarefrog the result is .
For the input data:
5 5 1 1 5 5 2 3 3 4 2
the correct result is:
4
Optimal route of the frog.
Task author: Piotr Stanczyk.