| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 1024 MB | 17 | 2 | 2 | 13.333% |
The swamp looks like a narrow lane with length $n$ covered by floating leaves sized 1ドル,ドル numbered from 1ドル$ to $n$ with a fly sitting on the top of each. A little toad is sitting on one of the leaves instead of a fly. Its name is Kvait and it is about to have lunch. It can jump to the bordering leaf or jump it over to the next one in any direction. When landing it eats a fly. Kvait is already quite a big toad and the leaves are unstable so when it jumps away the leaf starts sinking.
In order to have lunch Kvait needs to eat all of the flies. It starts his journey from the leaf with number $s$ and has to finish on the leaf with number $f$. Yet jumping to the bordering leaf takes more Kvait’s energy than skipping a leaf over. It is necessary to plan the toad’s movements to get lunch with minimal energy spent.
Single line contains three integers $n,ドル $s,ドル $f$ (2ドル \le n \le 10,000円,ドル 1ドル \le s, f \le n$) --- the number of leaves, number of a starting leaf and the number of the finish leaf respectively.
Output the minimal number of jumps to the bordering leaves required for the toad to have lunch. If there is no way to eat up, output a single number $-1$.
4 1 2
1