• [1559] Jump to the Top of Mountain

  • 时间限制: 1000 ms 内存限制: 65535 K
  • 问题描述
  • Have you played a game named Minecraft?
    In the game, there is a thing alloy you can not destroy, and its shape is a 1*1*1 area cube. I can only jump 1 meter at vertical height, it means I can jump from x meters height to y meters height when y is not more than x+1.

    Now, there is a rectangle field of m*n areas, each area is a positive interger X, X means the number of alloy in this area. You can only jump to four adjacent areas(up, down, left and right).

    At the beginning, you are at out of the rectangle field, and the height is 0 out of the rectangle field.
    Can you help me? I only want to know if I can jump to the peak of field?

  • 输入
  • Input ends of EOF.
    First line contains two positive integers m and n(3 <= m, n <= 100).
    Then m lines, each line contains n intergers X(0 <= X <= 10000).
  • 输出
  • If I can jump to the peak, output "YES", or output "NO".
  • 样例输入
  • 5 5
    2 2 1 2 2
    2 2 2 2 2
    2 2 3 2 2
    2 2 2 2 2
    2 2 2 2 2
    3 3
    2 1 2
    2 0 1
    1 1 3
    4 4
    1 1 1 1
    1 3 1 2
    1 1 1 3
    1 1 1 4
    4 4
    1 2 3 4
    8 7 6 5
    9 10 11 12
    16 15 14 13
    
  • 样例输出
  • YES
    NO
    YES
    YES
    
  • 提示
  • 来源
  • Hungar
  • 操作

显示春菜