CF131F.Present to Mom
普及+/提高
通过率:0%
时间限制:5.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
How many stars are there in the sky? A young programmer Polycarpus can't get this question out of his head! He took a photo of the starry sky using his digital camera and now he analyzes the resulting monochrome digital picture. The picture is represented by a rectangular matrix consisting of n lines each containing m characters. A character equals '1', if the corresponding photo pixel is white and '0', if it is black.
Polycarpus thinks that he has found a star on the photo if he finds a white pixel surrounded by four side-neighboring pixels that are also white:
1
111
1
a star on the photo
Polycarpus whats to cut out a rectangular area from the photo and give his mom as a present. This area should contain no less than k stars. The stars can intersect, have shared white pixels on the photo. The boy will cut out the rectangular area so that its borders will be parallel to the sides of the photo and the cuts will go straight between the pixel borders.
Now Polycarpus keeps wondering how many ways there are to cut an area out of the photo so that it met the conditions given above. Help Polycarpus find this number.
天空中有多少颗星星?年轻的程序员波利卡普斯一直被这个问题困扰着!他用数码相机拍摄了一张星空照片,现在正在分析这张得到的黑白数字图像。该图像由一个 $ n $ 行 $ m $ 列的矩形矩阵表示。矩阵中每个字符为 '1' 表示对应像素为白色,为 '0' 表示对应像素为黑色。
波利卡普斯认为,若在照片中发现一个白色像素,且其上下左右四个相邻(即四连通)像素也均为白色,则他就在照片中找到了一颗“星星”:
1
111
1
照片中的一颗星星
波利卡普斯想从照片中裁剪出一个矩形区域作为礼物送给妈妈。该矩形区域中至少应包含 $ k $ 颗星星。这些星星可以相交,即在照片上共享白色像素。裁剪出的矩形区域的边界需与照片的边平行,且裁剪线必须严格沿像素边界之间进行(即不能切过像素内部)。
现在波利卡普斯一直在思考:有多少种裁剪方式,能使得裁剪出的矩形区域满足上述条件?请帮助波利卡普斯求出这个数目。
输入格式
The first line of the input data contains three integers n, m and k (1 ≤ n, m ≤ 500;1 ≤ k ≤ nm). Then follow n lines, containing the description of the given photo as a sequence of lines. Each line contains m characters '0' or '1'.
输入数据的第一行包含三个整数 n、m 和 k(1 ≤ n, m ≤ 500;1 ≤ k ≤ nm)。接下来是 n 行,每行描述照片的一部分。每行包含 m 个字符,每个字符为 '0' 或 '1'。
输出格式
Print the required number of areas on the given photo.
在给定的照片上打印所需数量的区域。
输入输出样例
输入#1
4 6 2 111000 111100 011011 000111
输出#1
6
输入#2
5 5 4 11111 11111 11111 11111 11111
输出#2
9
说明/提示
We'll number the rows and columns below starting from 1, the coordinates (p, q) will denote a cell in row p, column q.
In the first sample Polycarpus should cut out any area containing a rectangle whose opposite corners lie in cells (1, 1) and (3, 4). Only rectangles with opposite corners in (1, 1) and (x, y), where x ≥ 3 and y ≥ 4 fit the conditions.
In the second sample any rectangle whose each side is no less than four, will do. The possible rectangle sizes are 4 × 4, 4 × 5, 5 × 4 and 5 × 5. Such figures can be cut in 4 ways, 2 ways, 2 ways and 1 way correspondingly.
Please do not use the %lld specificator to read or write 64-bit integers in C++. It is preferred to use cin, cout streams or the %I64d specificator.
我们将从 1 开始对下面的行和列进行编号,坐标 (p,q) 表示第 p 行、第 q 列的格子。
在第一个样例中,Polycarpus 应当裁剪出任意一个包含以格子 (1,1) 和 (3,4) 为对角顶点的矩形的区域。只有以 (1,1) 和 (x,y) 为对角顶点(其中 x ≥ 3 且 y ≥ 4)的矩形才满足条件。
在第二个样例中,任意边长均不小于 4 的矩形均可。可能的矩形尺寸为 4 × 4、4 × 5、5 × 4 和 5 × 5。这些图形分别可被裁剪出 4 种、2 种、2 种和 1 种方式。
请勿在 C++ 中使用 %lld 特定格式说明符来读取或写入 64 位整数。推荐使用 cin、cout 流,或 %I64d 特定格式说明符。
输入解题思路,AI测评打分。不知道怎么写?