#D. 骑士巡游(普通)

    传统题 1000ms 128MiB

骑士巡游(普通)

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目描述

马在中国象棋以日字形规则移动,给定 n×mn \times m 大小的棋盘,以及马的初始位置 (x,y)(x,y) 和目标位置 (s,t)(s,t),要求不能重复经过棋盘上的同一个点,计算马至少走多少步可以到达目标位置。

输入格式

测试数据包含一行,为六个整数,分别为棋盘的大小以及初始位置坐标 n,m,x,y,s,tn,m,x,y,s,t

输出格式

包含一行,为一个整数,表示马能到达目标位置的最小步数。

3 3 1 1 1 3
2

数据范围

1x,sn51 \leq x,s \leq n \leq 5

1y,tm51 \leq y,t \leq m \leq 5

迷宫专辑

未认领
状态
已结束
题目
6
开始时间
2023-12-9 0:00
截止时间
2023-12-30 23:59
可延期
24 小时