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

15242번 - Knight 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB22018016886.598%

문제

In Chess, the knight is the weirdest of all the pieces. To begin with, the piece is actually a horse without any human riding it. The second reason is its movement pattern. It can move 2 cells forward and one to the side. Below you can see all the possible destinations of a knight.

With a movement pattern so weird, it is complicated to know what’s the shortest path between two board squares. Can you write a program that computes the minimum number of movements needed to move a knight from one square to another? Remember that a chessboard has 8 rows and 8 columns. Also in the standard notation, the columns are represented by letters from a to h.

입력

The input will contain 2 lines. The first line will be the starting position of the knight and the second line will specify its final position.

출력

Output a single integer specifying the minimum number of moves for the knight to get from it’s starting position to it’s final position on the board.

제한

예제 입력 1

h1
a8

예제 출력 1

6

예제 입력 2

b1
b1

예제 출력 2

0

예제 입력 3

e2
e4

예제 출력 3

2

힌트

출처

Olympiad > All-Ireland Programming Olympiad > 2017 AIPO National Finals 5번

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

출처

대학교 대회

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

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