序数和的编号的问题,数列配对运用 C语言的程序的设计的形式怎么做

Problem Description
-- Hello, may I speak to Petrov, please? Hello, my darling... You know, there was a little accident at our home... No, no, don't worry, your computer was not damaged. It is only a bit dirty there now. Well, I should say it's very dirty there and I'm at my Mom's now. Of course, I'll clean it... When? Well, maybe when I have my vacation. What? Well, when we are back from Turkey... the next vacation then. I'll stay at Mother's until then, and you may live here also. No, no, I don't insist, sure, you may stay at home if you wish so. I prepared boots for you, they are at the door. But please, don't make it worse, before you step on a clean floor, change your boots, put on your slippers, they are at the door also. Take them with you when you walk through the dirt. And when you walk on a clean floor, take the boots with you. You see, the dirt is in different places. OK, my love? Thank you!

It is not a great pleasure to change boots each time you get from a clean floor to a dirty floor and vice versa, it's easier to walk extra several meters. So it is necessary to find a way of getting from one place in the apartment to another with the minimal possible number of boots changes; and among these paths the shortest one must be found.

To begin with, it is natural to determine an optimal way of passing the Most Important Route: from the computer to the refrigerator.

Input
The first line of the input contains two integers M and N, which are dimensions of the apartment (in meters), 1 ≤ N, M ≤ 1000. The two integers in the second line are the coordinates of the computer, and the third line contains the coordinates of the refrigerator. Each of the following M lines contains N symbols; this is the plan of the apartment. On the plan, 1 denotes a clean square, 2 denotes a dirty square, and 0 is either a wall or a square of impassable dirt. It is possible to get from one square to another if they have a common vertex. When you pass from a clean square to a dirty one or vice versa, you must change shoes. The computer and the refrigerator are not on the squares marked with 0.

The upper left square of the plan has coordinates (1, 1).

Output
You should output two integers in one line separated with a space. The first integer is the length of the shortest path (the number of squares on this path including the first and the last squares) with the minimal possible number of boots changes. The second number is the number of boots changes. If it is impossible to get from the computer to the refrigerator, you should output 0 0.

Sample Input
3 7
1 1
3 7
1200121
1212020
1112021

Sample Output
8 4

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!

相似问题

2
求数列的和,用C语言,谢谢
1
C语言求数列的的第n项的和
1
一个数列数组的求和再求比率的问题,如何利用C语言的方法编程算法解决
0
数列递推公式的实现,采用C语言的运用循环的方式,如何实现这个问题的解决?
2
输入n(n<100)个数,将它与最前面的数交换后输出这些数。如何运用通过C语言的做法来解决这个问题的?
0
兔子繁殖的数列的问题,运用C语言的技术如何才能解决的?
0
综合运用C语言的编程的技术如何解决这里的数列求和的算法问题呢
0
数列对的问题,如何运用C语言的方式作答,利用C语言如何解决这个问题
0
这个数据结构问题运用数列递推的思路怎么使用C语言解决这个问题
0
二进制线段数列的枚举的典型问题,使用C语言编写程序设计解决这个算法是怎么做的
0
菲波那契数列(Fibonacci numbers)的一个算法问题,运用C语言实现的形式和做法
0
数列的翻转表的一个算法的问题的求解,用C语言的程序编写怎么实现的啊
0
数列数组的增加删除修改寻找的一个问题,采用C语言的程序设计的方式怎么实现代码的编写
0
数列的单向遍历的方式如何解决这个问题啊,C语言程序代码具体怎么实现
0
一个数列级数的判断计算的问题的解答的方式,如何利用C语言的程序设计的方式来实现
0
等比数列的求解问题,根据项数得到值的方式,用C程序的设计思想来实现
0
判断数列是否达到最大和的算法,怎么利用C程序的语言设计技术来编写
0
三次方的数列求和值比较大的处理方式,运用C程序的编程技术来实现的
0
序列上截取一个最大的和的连续数列的问题,怎么采用C程序的语言设计的办法
0
修改数量最少的元素,使得这个数列严格递增,用C语言计算最小的修改个数