luogu#P2733. [USACO3.3] 家的范围 Home on the Range

[USACO3.3] 家的范围 Home on the Range

Background

{{FJ grazes his cows on a square pasture with side length N(2N250)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 11 square mile).}}

Problem Description

{{FJ needs to count how many square pastures can be grazed (at least 2×22\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×22\times2 there are. Of course, grazing regions may overlap.}}

Input Format

{{Line 1: NN, the side length of the pasture. Lines 2 to N+1N+1: NN characters with no spaces. 00 indicates that cell is damaged; 11 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.}}

6
101111
001111
111111
001111
101101
111001
2 10
3 4
4 1

Hint

{{Translation from NOCOW. USACO Training Section 3.3.}}

Translated by ChatGPT 5