P2733 {{[USACO3.3] Home on the Range}}

Background

{{FJ grazes his cows on a square pasture with side length $N (2 \le N \le 250)$ miles (for some reason, his cows graze only on square pastures). Unfortunately, his cows have damaged some land (these patches are each $1$ square mile).}}

Description

{{FJ needs to count how many square pastures can be grazed (at least $2\times2$ in size, and no cell in this shape is damaged; in other words, all cells are "1"). Your task is to count, in the given data, how many grazeable square pastures of size at least $2\times2$ there are. Of course, grazing regions may overlap.}}

Input Format

{{Line 1: $N$, the side length of the pasture. Lines 2 to $N+1$: $N$ characters with no spaces. $0$ indicates that cell is damaged; $1$ indicates intact land.}}

Output Format

{{Output the side length and the count of such squares that exist, one size per line, in increasing order of side length.}}

Explanation/Hint

{{Translation from NOCOW. USACO Training Section 3.3.}} Translated by ChatGPT 5