Logo
(追記) (追記ここまで)

34388번 - 3-Puzzle 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB29161451.852%

문제

Your friend needs help solving a 15ドル$-Puzzle, so to warm up, you solve the 3ドル$-Puzzle instead. A 3ドル$-Puzzle consists of a 2ドル \times 2$ grid containing 3ドル$ tiles numbered 1ドル$ through 3ドル$ and one empty space. The goal is to slide the tiles around so that they are in ascending row-major order and the empty space is on the bottom right like this:

1ドル$ 2ドル$
3ドル$

Given the starting position of a 3ドル$-Puzzle, find the minimum number of moves it takes to solve the puzzle. Here's an example of how sample input 1ドル$ can be solved in 3ドル$ moves:

Starting position:

2ドル$
1ドル$ 3ドル$

After 1ドル$ move:

2ドル$
1ドル$ 3ドル$

After 2ドル$ moves:

1ドル$ 2ドル$
3ドル$

After 3ドル$ moves:

1ドル$ 2ドル$
3ドル$

입력

The input will consist of exactly 2ドル$ lines, each containing exactly 2ドル$ characters.

Each character is either a number 1ドル$ through 3ドル$ (representing one of the tiles) or a dash (-) (the empty space).

The puzzle state represented by the input is guaranteed to be a solvable configuration.

출력

Output a singe integer, indicating the minimum number of moves required to solve the puzzle from the provided starting position, or 0ドル$ if it's already in the solved position.

제한

예제 입력 1

2-
13

예제 출력 1

3

예제 입력 2

-3
21

예제 출력 2

6

노트

출처

School > CS@Mines > CS@Mines HSPC 2022 > Beginner I번

  • 문제를 만든 사람: Adam Sandstedt
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /