编程介的小学生 2020-01-12 14:07 采纳率: 20.5%
浏览 101

Count Cross 交叉的计算

Problem 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

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 用windows做服务的同志有吗
    • ¥60 求一个简单的网页(标签-安全|关键词-上传)
    • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图