포럼
문제 ICPC00353

H. Hidden Art

설명

You have recently moved to a new home, and you are almost done decorating it. However, you still feel like something is missing: you need some art on the wall! Since you have already spent most of your budget on the furniture, you decide to go to the cheapest art shop there is: the Budget Art Printing Company (BAPC).

At the BAPC, you can buy infinitely large sheets of paper on which a decoration is printed. Such a decoration consists of a rectangular pattern which is repeated in all directions. This pattern in turn consists of square pixels that are colored white, red, green or blue. After buying a sheet of paper, customers may then cut out a part of the sheet to create their very own artwork.

You have just found a pattern of pixels you like, but before you have it printed you decide to check whether it is possible to cut a beautiful artwork from it. You consider an artwork beautiful if it satisfies the following properties:
- It is cut out along pixel boundaries.
- It is a square.
- The pixels in the four corners of the square have four different colors.

Is there a beautiful artwork hidden in this infinite sheet printed with the selected pattern?

As an example, consider the first sample input, visualized in Figure . In the infinitely repeated pattern, it is possible to find several beautiful artworks.

제약
입력 형식

The input consists of:
- One line with two integers \(h\) and \(w\) (\(1 \leq h \leq 4000\), \(1 \leq w \leq 50\)), the height and width of the chosen pattern.
- \(h\) lines, each with a string of \(w\) characters \(c\) (\(c \in \{\texttt{w}, \texttt{r}, \texttt{g}, \texttt{b}\}\)), describing the pattern.

출력 형식

If it is possible to cut out a beautiful artwork from the sheet with the selected pattern, output "possible", otherwise output "impossible".

예제 1
입력
3 2
wr
wg
bg
출력
possible
예제 2
입력
2 4
gbrw
wbgr
출력
impossible
예제 3
입력
6 6
bwwrrr
bbbrrr
bbbrwr
rrrggg
rrrgww
rwwggg
출력
possible
문제 정보

생성자가 기록되지 않았습니다.

출처 ICPC BAPC 2023

평가 및 의견

H. Hidden Art

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 1 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

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

풀이 제출

H. Hidden Art

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