시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 (추가 시간 없음) | 1024 MB | 13 | 8 | 8 | 61.538% |
You may know the game Where is Waldo?. In this game you need to find a person named Waldo in a crowd of people. This problem is kind of similar. You need to find an axis-aligned rectangle of minimal area which contains the letters W
, A
, L
, D
and O
and those letters are hidden in a crowd of other letters.
Figure L.1: Illustration of the second sample case.
The input consists of:
A
-Z
, the grid of letters.Output the area of the smallest axis-aligned rectangle which contains at least one of each of the letters W
, A
, L
, D
and O
. If there is no rectangle containing those letters, output impossible
.
5 5 ABCDE FGHIJ KLMNO PQRST VWXYZ
25
5 10 ABCDEABCDE FGHIJFGHIJ KLMNOKLMNO PQRSTPQRST VWXYZVWXYZ
20
5 10 WAALDLODOW AWWLAOODOW LOLADOWALO ADALLLWWOL WWOOAAAALO
5
2 3 WAL TER
impossible
ICPC > Regionals > Europe > Northwestern European Regional Contest > German Collegiate Programming Contest > GCPC 2021 L번