10334 - 家的范围

农民约翰在一片边长是N (2 <= N <= 250)英里的正方形牧场上放牧他的奶牛。 (因为一些原因,他的奶牛只在正方形的牧场上吃草。) 遗憾的是,他的奶牛已经毁坏一些土地。( 一些1平方英里的正方形) 农民约翰需要统计那些可以放牧奶牛的正方形牧场(至少是2x2的,在这些较大的正方形中没有小于1x1的部分被分割毁坏)。 你的工作要在被供应的数据组里面统计所有不同的正方形放牧区域(>2x2)的个数。 当然,放牧区域可能是重叠。

输入

第 1 行:   N,牧区的边长。

第 2 到 n+1行: N个没有空格分开的字符。

0 表示 "那一个区段被毁坏了";1 表示 " 准备好被吃"。

输出

输出那些存在的正方形的大小和个数,一种一行。

样例

输入

6
101111
001111
111111
001111
101101
111001

输出

2 10
3 4
4 1

提示

Home on the Range

Farmer John grazes his cows on a large, square field N (2 <= N <= 250) miles on a side (because, for some reason, his cows will only graze on precisely square land segments). Regrettably, the cows have ravaged some of the land (always in 1 mile square increments). FJ needs to map the remaining squares (at least 2x2 on a side) on which his cows can graze (in these larger squares, no 1x1 mile segments are ravaged).

Your task is to count up all the various square grazing areas within the supplied dataset and report the number of square grazing areas (of sizes >= 2x2) remaining. Of course, grazing areas may overlap for purposes of this report.

PROGRAM NAME: range INPUT FORMAT Line 1: N, the number of miles on each side of the field. Line 2..N+1: N characters with no spaces. 0 represents "ravaged for that block; 1 represents "ready to eat".

SAMPLE INPUT (file range.in) 6 101111 001111 111111 001111 101101 111001

OUTPUT FORMAT Potentially several lines with the size of the square and the number of such squares that exist. Order them in ascending order from smallest to largest size.

SAMPLE OUTPUT (file range.out) 2 10 3 4 4 1

时间限制 1 秒
内存限制 128 MB
统计
上一题 下一题