5×5格2D矩阵声明 [英] 2D MATRIX statement for 5 x 5 Grid

查看:175
本文介绍了5×5格2D矩阵声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于5×5格,包括编号从1到25瓦和一组5起始终点对。
对于每一对,发现从起点到终点的路径。
路径应满足以下条件:

Given a 5 x 5 Grid comprising of tiles numbered from 1 to 25 and a set of 5 start-end point pairs. For each pair,find a path from the start point to the end point. The paths should meet the below conditions:

a)只有水平和垂直移动允许的。

a) Only Horizontal and Vertical moves allowed.

b)否两条路径应该重叠。

b) No two paths should overlap.

C)路径应覆盖整个电网

c) Paths should cover the entire grid

输入包括5条线路。
每行有两个空格分开的整数,开始和结束点。

Input consist of 5 lines. Each line contains two space-separated integers,Starting and Ending point.

输出:打印5行。每行包括空格分开的整数,对于相应的起始端对的路径。假定这样的路径总是存在的。在多个解的情况下,打印它们中的任何一个。

Output: Print 5 lines. Each line consisting of space-separated integers,the path for the corresponding start-end pair. Assume that such a path Always exists. In case of Multiple Solution,print any one of them.

采样输入

1月22日

4月17日

5月18日

9月13日

20 23

样本输出

1 6 11 16 21 22

1 6 11 16 21 22

4 3 2 7 12 17

4 3 2 7 12 17

10 10 15 14 19 18

5 10 15 14 19 18

9 8月13日

20 25 24 23

20 25 24 23

推荐答案

我觉得应该有限制或缺乏有关输入一些信息(起点和终点)
因为如果我们把下面的输入则覆盖整个网格是不可能的
1月22日,
6 7,
11月12日,
16 17,
8 9

i think there should be restriction or it lacks some more information about the input ( start point and endpoint) because if we take following input then covering whole grid is not possible 1 22, 6 7, 11 12, 16 17, 8 9

这篇关于5×5格2D矩阵声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆