406791: GYM102556 G Riana and Gallant Guards

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

G. Riana and Gallant Guardstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Due to her success as a singer, songwriter, DISCS PrO problem setter, and CEO of the cosmetics brand Fenwick Beautree, Riana has been having trouble dealing with aggressive fans and rude boys. She can't use her usual strategy of hiding under her umbrella because it hasn't been raining, raining.

In spite of difficult fans, Riana is planning an event for launching her new product, the Matte Flow Lipstick. She needs your help to make the product launch work, work, work, work, work. As much as she believes that her fans are beautiful like diamonds in the sky, she admits that there can be some who stir up trouble before her events can even start.

Riana's launch venue has a width of $$$W$$$ and a length of $$$L$$$ when viewed from the top, and she has a reliable team of bodyguards who can call as much backup to the venue as needed. Their years of experience have helped them develop an optimal strategy for minimizing the access of troublemakers to the event grounds! They don't want to alarm Riana's guests during her events, so they assemble gradually.

Let's say the first bodyguard at the venue is positioned as follows:

That bodyguard will call at most four ($$$4$$$) backup bodyguards who will, after one second, position themselves exactly one unit north, exactly one unit south, exactly one unit east, and exactly one unit west of the original bodyguard if the spot is vacant and does not go beyond the venue. Those bodyguards will then do the same thing immediately after they position themselves, and even more bodyguards arrive after another second. This process will continue until all spots in the venue are taken. This is illustrated as follows:

Unfortunately, the troublemaking fans have learned this and will plan on using the exact same strategy. Troublemaking fans also arrive and position themselves at exactly one unit north, exactly one unit south, exactly one unit east, and exactly one unit west of the fan that called them, one second after they are called. Each newly arrived troublemaker will also call more troublemakers immediately after they position themselves, and even more troublemakers arrive after another second, and so on.

However, Riana's bodyguards took an oath. If at any point they will have to compete with the fans for a spot in the venue, they'll stick it out 'til the end and will be able to take the spot before Riana's fans do!

Riana wants to position the first bodyguard such that they minimize the troublemakers at the venue. If you are given the starting position $$$(X,Y)$$$ of the first troublemaking fan, where should Riana's first bodyguard be positioned? Note that $$$X$$$ corresponds to the row where the troublemaker is, and $$$Y$$$ corresponds to the column. The position $$$(1,1)$$$ is located at the upper-left corner of the venue when viewed from the top.

Input

The first line of input contains two integers, $$$W$$$ and $$$L$$$ which represent the width and the length of the venue respectively. $$$W$$$ and $$$L$$$ are guaranteed to be between $$$1$$$ and $$$1000$$$ (both inclusive).

The second line of input contains two integers, $$$X$$$ and $$$Y$$$ which correspond to the position $$$(X,Y)$$$ of the first troublemaking fan. $$$X$$$ is guaranteed to be between $$$1$$$ and $$$W$$$ (both inclusive). $$$Y$$$ is guaranteed to be between $$$1$$$ and $$$L$$$ (both inclusive).

Output

Output one integer which represents the minimum number of troublemakers that will be at the venue after it becomes fully occupied, if the first bodyguard is positioned at the optimal spot. Output this number only if the number of bodyguards is strictly greater than the number of troublemakers. Otherwise, output I don't wanna do this anymore!

ExamplesInput
4 3
3 2
Output
4
Input
1000 1000
306 865
Output
41616
Note

For the first sample test case, the first fan is positioned as follows:

It can be shown that if the first bodyguard is stationed at the right location, the number of troublemakers is $$$4$$$.

加入题单

上一题 下一题 算法标签: