• [G] Get Mine Cleared

  • 时间限制: 1000 ms 内存限制: 65535 K
  • 问题描述
  • Mine Clearance is a puzzle game.
    Now we need to write a Mine Clearance. We know the game has an interface of a matrix M * N.
    The player should click T times. Each click has its own coordinate x and y.

    You need output each status after a click, like the real Mine Clearance - Floodfill when it's blank.

    You should output 'N' if that area is still unknown. You should output the number of mines that occupy the surroundding eight grids.

    If the player clicked the mine, you should output all the grids and output "fail". If the player cleared all the mines, you should output all the grids and output "success".
    (Note that M and N start from 1. Each click might on the known grid)
  • 输入
  • The first line is a integer K, indicates the number of cases.
    Then follow K cases.
    The first line of each case is three integers T, M, N. (0 < M, N < 21, T < M * N)
    Then follows the matrix.
    Next T lines follow T clicks. Each click is two integer x and y.
    Every click must be outputted.
  • 输出
  • for each click, you should have a output. it has two blank lines between each case, and have one blank lines between each click in the same case.
  • 样例输入
  • 2
    5 5 5
    0 1 1 0 0
    0 0 0 1 0
    1 1 0 1 1
    0 0 1 0 0
    1 1 1 1 0
    1 1
    2 2
    3 3
    4 4
    5 5
    1 5 5
    1 1 1 0 0
    0 0 0 1 0
    1 1 0 1 1
    0 0 1 0 0
    1 1 1 1 0
    1 1
    
  • 样例输出
  • 1 N N N N
    N N N N N
    N N N N N
    N N N N N
    N N N N N
    
    1 N N N N
    N 4 N N N
    N N N N N
    N N N N N
    N N N N N
    
    1 N N N N
    N 4 N N N
    N N 4 N N
    N N N N N
    N N N N N
    	
    1 N N N N
    N 4 N N N
    N N 4 N N
    N N N 5 N
    N N N N N
    
    1 N N N N
    N 4 N N N
    N N 4 N N
    N N N 5 N
    N N N N 1
    	
    
    1 N N N N
    N N N N N
    N N N N N
    N N N N N
    N N N N N
    	
    fail
    
  • 提示
  • 来源
  • NE123123
  • 操作

显示春菜