RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
USACO0284 파일 입출력

Where's Bessie?

Gold I 골드 I
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

Always known for being quite tech-savy, Farmer John is testing out his new
automated drone-mounted cow locator camera, which supposedly can take a picture
of his field and automatically figure out the location of cows. Unfortunately,
the camera does not include a very good algorithm for finding cows, so FJ needs
your help developing a better one.

The overhead image of his farm taken by the camera is described by an
\(N \times N\) grid of characters, each in the range \(A \ldots Z\), representing
one of 26 possible colors. Farmer John figures the best way to define a
potential cow location (PCL) is as follows: A PCL is a rectangular sub-grid
(possibly the entire image) with sides parallel to the image sides, not
contained within any other PCL (so no smaller subset of a PCL is also a PCL).
Furthermore, a PCL must satisfy the following property: focusing on just the
contents of the rectangle and ignoring the rest of the image, exactly two colors
must be present, one forming a contiguous region and one forming two or more
contiguous regions.

For example, a rectangle with contents

AAAAA
ABABA
AAABB

would constitute a PCL, since the A's form a single contiguous region and the
B's form more than one contiguous region. The interpretation is a cow of color
A with spots of color B.

A region is "contiguous" if you can traverse the entire region by moving
repeatedly from one cell in the region to another cell in the region taking
steps up, down, left, or right.

Given the image returned by FJ's camera, please count the number of PCLs.

Problem credits: Brian Dean

제약

Problem credits: Brian Dean

입력 형식

The first line of input contains \(N\), the size of the grid (\(1 \leq N \leq 20\)).
The next \(N\) lines describe the image, each consisting of \(N\) characters.

출력 형식

Print a count of the number of PCLs in the image.

파일 입력 / 출력
이 문제는 표준 입출력을 사용하지 않습니다. 프로그램은 다음 파일을 읽고 써야 합니다:
입력을 읽을 파일 where.in
출력을 쓸 파일 where.out
예제 1
입력
4
ABBC
BBBC
AABB
ABBC
출력
2
설명

In this example, the two PCLs are the rectangles with contents

ABB
BBB
AAB
ABB

and

BC
BC
BB
BC
문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2016-2017 > US Open > Silver

태그

평가 및 의견

Where's Bessie?

개요
출제자 난이도 Gold I 골드 I 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Where's Bessie?

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8