22220_DensityCenter

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

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

Pro.ID

22220

Title

Density Center

Title链接

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

AC

3

Submit

20

Ratio

15.00%

时间&空间限制

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

    A peg board is drilled with a square matrix of holes, into which pegs might be inserted. The dimension of a peg board is the number of holes in a row or column, and is always a positive power of 2; i.e. 2n for some n ≥ 0. The density of a peg board is the number of holes containing pegs.

    The density center of a peg board is a hole coordinate on the board defined recursively:

    • If the dimension is 20, the density center is its one and only coordinate.

    • If the dimension is 2n where n > 0, the density center is the density center of the quadrant (upper left, upper right, lower left, or lower right) having the highest density. If there is a tie for highest density, the priority order (from highest to lowest) is (upper left, upper right, lower left, lower right).

    Write a program that inputs a peg board and finds its density center.

    输入

    The first line of input contains the dimension of the peg board, which is 2n for some n ≥ 0. The remaining 2n lines represent the peg board, with each line containing 2n characters. A blank character represents an empty hole and a non-blank character (e.g. o) represents a hole containing a peg.

    输出

    Description

    A peg board is drilled with a square matrix of holes, into which pegs might be inserted. The dimension of a peg board is the number of holes in a row or column, and is always a positive power of 2; i.e. 2n for some n ≥ 0. The density of a peg board is the number of holes containing pegs.

    The density center of a peg board is a hole coordinate on the board defined recursively:

    • If the dimension is 20, the density center is its one and only coordinate.

    • If the dimension is 2n where n > 0, the density center is the density center of the quadrant (upper left, upper right, lower left, or lower right) having the highest density. If there is a tie for highest density, the priority order (from highest to lowest) is (upper left, upper right, lower left, lower right).

    Write a program that inputs a peg board and finds its density center.

    Input

    The first line of input contains the dimension of the peg board, which is 2n for some n ≥ 0. The remaining 2n lines represent the peg board, with each line containing 2n characters. A blank character represents an empty hole and a non-blank character (e.g. o) represents a hole containing a peg.

    Output

    Output the peg board as it appears in the input, except the coordinate of the density center, which should be marked with the character X.

    Sample Input

    16
      o oo     o  o
    o     o   oo  o
     o   o ooo o  o
       o   oo    o
    o        o  o  
     o          o o
    o     o      ooo
    o  o      o   oo
       o  oo  o  o
    oo  oooooo  o o
    o   oo oo  o ooo
    o oooo    o oo
    o ooo  oo  oo  o
    o   o oo  o   oo
    oooo    o oo   o
    o      o    o  

    Sample Output

      o oo     o  o
    o     o   oo  o
     o   o ooo o  o
       o   oo    o
    o        o  o  
     o          o o
    o     o      ooo
    o  o      o   oo
       o  oo  o  o
    oo  oooooo  o o
    o   Xo oo  o ooo
    o oooo    o oo
    o ooo  oo  oo  o
    o   o oo  o   oo
    oooo    o oo   o
    o      o    o  

    样例输入

    16
      o oo     o  o
    o     o   oo  o
     o   o ooo o  o
       o   oo    o
    o        o  o  
     o          o o
    o     o      ooo
    o  o      o   oo
       o  oo  o  o
    oo  oooooo  o o
    o   oo oo  o ooo
    o oooo    o oo
    o ooo  oo  oo  o
    o   o oo  o   oo
    oooo    o oo   o
    o      o    o  

    样例输出

      o oo     o  o
    o     o   oo  o
     o   o ooo o  o
       o   oo    o
    o        o  o  
     o          o o
    o     o      ooo
    o  o      o   oo
       o  oo  o  o
    oo  oooooo  o o
    o   Xo oo  o ooo
    o oooo    o oo
    o ooo  oo  oo  o
    o   o oo  o   oo
    oooo    o oo   o
    o      o    o  

    提示

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部