22227_Rooks

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

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

Pro.ID

22227

Title

Rooks

Title链接

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

AC

15

Submit

48

Ratio

31.25%

时间&空间限制

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

    You have unexpectedly become the owner of a large chessboard, having fifteen squares to each side. Because you do not know how to play chess on such a large board, you find an alternative way to make use of it.

    In chess, a rook attacks all squares that are in the same row or column of the chessboard as it is. For the purposes of this problem, we define a rook as also attacking the square on which it is already standing.

    Given a set of chessboard squares, how many rooks are needed to attack all of them?

    输入

    Input consists of a number of test cases. Each test case consists of fifteen lines each containing fifteen characters depicting the chess board. Each character is either a period (.) or a hash (#). Every chessboard square depicted by a hash must be attacked by a rook. After all the test cases, one more line of input appears. This line contains the word END.

    输出

    Description

    You have unexpectedly become the owner of a large chessboard, having fifteen squares to each side. Because you do not know how to play chess on such a large board, you find an alternative way to make use of it.

    In chess, a rook attacks all squares that are in the same row or column of the chessboard as it is. For the purposes of this problem, we define a rook as also attacking the square on which it is already standing.

    Given a set of chessboard squares, how many rooks are needed to attack all of them?

    Input

    Input consists of a number of test cases. Each test case consists of fifteen lines each containing fifteen characters depicting the chess board. Each character is either a period (.) or a hash (#). Every chessboard square depicted by a hash must be attacked by a rook. After all the test cases, one more line of input appears. This line contains the word END.

    Output

    Output consists of exactly one line for each test case. The line contains a single integer, the minimum number of rooks that must be placed on the chess board so that every square marked with a hash is attacked.

    Sample Input

    ...............
    ...............
    ...............
    ...............
    ...............
    ...............
    ...............
    .......#.......
    ...............
    ...............
    ...............
    ...............
    ...............
    ...............
    ...............
    END

    Sample Output

    1

    Source

    样例输入

    ...............
    ...............
    ...............
    ...............
    ...............
    ...............
    ...............
    .......#.......
    ...............
    ...............
    ...............
    ...............
    ...............
    ...............
    ...............
    END

    样例输出

    1

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部