21822_CountCross

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

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

Pro.ID

21822

Title

Count Cross

Title链接

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

AC

0

Submit

0

Ratio

-

时间&空间限制

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

    Given a MM×NN grid with different colors (black and white) on each cell, your task is to calculate the total amount of crosses of black color. We say there exists a black cross centered at the black cell (x, y) if there are four positive integer L, R, U, D that the cell (x, y-L), (x, y+R), (x-U, y), (x+D, y) are all black. Note that if two crosses have the same center but different L, R, U, D, we consider they are distinct. We use 1 to describe black.

    For example

    00100
    00100
    11111
    00100
    00100
    00000

    There are 16 black crosses.

    The MM and NN are large, so we divide the matrix into M×N rectangle blocks. If two cells are in the same block, their colors are same.

    So we can divide the sample into 4×3 blocks.

    输入

    There are at most 100 cases.

    In every case, there are two integers, M, N in the first line. ( 1 ≤ M, N ≤ 50 )

    The next line contains M positive integers which are less than or equals to 50. The p-th integer describe the p-th row block's height.

    The next line contains N positive integers which are less than or equals to 50. The p-th integer describe the p-th colomn block's width.

    The following M lines each has a string which contain N digits.The q-th digit in the p-th line describe the color of the q-th colomn block in the p-th row.

    输出

    Description

    Given a MM×NN grid with different colors (black and white) on each cell, your task is to calculate the total amount of crosses of black color. We say there exists a black cross centered at the black cell (x, y) if there are four positive integer L, R, U, D that the cell (x, y-L), (x, y+R), (x-U, y), (x+D, y) are all black. Note that if two crosses have the same center but different L, R, U, D, we consider they are distinct. We use 1 to describe black.

    For example

    00100
    00100
    11111
    00100
    00100
    00000

    There are 16 black crosses.

    The MM and NN are large, so we divide the matrix into M×N rectangle blocks. If two cells are in the same block, their colors are same.

    So we can divide the sample into 4×3 blocks.

    Input

    There are at most 100 cases.

    In every case, there are two integers, M, N in the first line. ( 1 ≤ M, N ≤ 50 )

    The next line contains M positive integers which are less than or equals to 50. The p-th integer describe the p-th row block's height.

    The next line contains N positive integers which are less than or equals to 50. The p-th integer describe the p-th colomn block's width.

    The following M lines each has a string which contain N digits.The q-th digit in the p-th line describe the color of the q-th colomn block in the p-th row.

    Output

    Output the answer to each case.

    Sample Input

    4 3
    2 1 2 1
    2 1 2
    010
    111
    010
    000

    Sample Output

    16

    Source

    样例输入

    4 3
    2 1 2 1
    2 1 2
    010
    111
    010
    000

    样例输出

    16

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部