22046_Max'sgame

2022-5-16 18:21| 发布者: Hocassian| 查看: 25| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-4-8950666595200-Problem List-采集的数据-后羿采集器.html

Pro.ID

22046

Title

Max's game

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=22046

AC

0

Submit

5

Ratio

0.00%

时间&空间限制

  • Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 6/65536 K (Java/Others)
  • 描述

    Max is lately playing a game. Given a n*m board, there are only two types of grid on it: # and @. And the rule is simple: Given a start position to Max, and Max can move to four direction for each step, up, down, left, right. When moving between two same type grids, it costs zero, otherwise, it costs one. Now, Max gets two different positions on the board: the start position and the target position, he wants to know how many costs he need to spend to achieve the game at least.

    输入

    Input contains multiple test data sets.

    For each data set, first comes two integers in one line: n, m ( 1 ≤ n, m ≤ 500 ), stands for the number of row and the number of column of the board. Then comes n lines with m grid characters per each. The characters are only @ or #. Then four integers in one line follow: x1, y1, x2, y2 ( 0 ≤ x1, x2 < n,   0 ≤ y1, y2 < m ) which is the start position and the end position correspondingly.

    Input is terminated by EOF.

    输出

    Description

    Max is lately playing a game. Given a n*m board, there are only two types of grid on it: # and @. And the rule is simple: Given a start position to Max, and Max can move to four direction for each step, up, down, left, right. When moving between two same type grids, it costs zero, otherwise, it costs one. Now, Max gets two different positions on the board: the start position and the target position, he wants to know how many costs he need to spend to achieve the game at least.

    Input

    Input contains multiple test data sets.

    For each data set, first comes two integers in one line: n, m ( 1 ≤ n, m ≤ 500 ), stands for the number of row and the number of column of the board. Then comes n lines with m grid characters per each. The characters are only @ or #. Then four integers in one line follow: x1, y1, x2, y2 ( 0 ≤ x1, x2 < n,   0 ≤ y1, y2 < m ) which is the start position and the end position correspondingly.

    Input is terminated by EOF.

    Output

    For each test data set, one output data set should be generated as follow:

    Generates one line containing one integer which indicates the minimum cost Max need to take for the game.

    Sample Input

    2 2
    @#
    #@
    0 0 1 1
    2 2
    @@
    @#
    0 1 1 0

    Sample Output

    2
    0

    Source

    样例输入

    2 2
    @#
    #@
    0 0 1 1
    2 2
    @@
    @#
    0 1 1 0

    样例输出

    2
    0

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部