#P1852. 跳跳棋
跳跳棋
Description
Jumping Checkers is played on a number line. Pieces can only be placed on integer points. No position may contain more than one piece.

We use Jumping Checkers to play a simple game: there are pieces on the board at positions . We want to move them, using the fewest jumps, so that their positions become . (The pieces are indistinguishable.)
The rule for a jump is simple: choose any piece and jump it over a pivot piece. After the jump, the distance between the two pieces remains unchanged. Each move may jump over exactly piece.
Write a program to first determine whether the task is possible. If it is, output the minimum number of jumps required.
Input Format
The first line contains three integers, the current positions (pairwise distinct).
The second line contains three integers, the target positions (pairwise distinct).
Output Format
If there is no solution, output a single line NO.
If it is reachable, output the first line YES, and the second line the minimum number of jumps.
1 2 3
0 3 5
YES
2
Hint
Constraints
- For of the testdata, the absolute value of each input integer does not exceed .
- For of the testdata, the absolute value of each input integer does not exceed .
- For of the testdata, the absolute value does not exceed .
Translated by ChatGPT 5
京公网安备 11011102002149号