Logo
(追記) (追記ここまで)

18077번 - King’s Children 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 512 MB50181845.000%

문제

The King of Byteland has decided to divide the country into provinces, one for each of his children.

The map of Byteland is a rectangular matrix consisting of n rows and m columns. Each king’s child has a castle, located in one of the cells of the matrix (each cell contains at most one castle). King wants to split the Byteland in the following way:

  • Each province must be a rectangle.
  • Each cell of the Byteland territory must belong to exactly one province.
  • Each province must contain the castle of exactly one king’s child, the owner of this province.

The king loves all his children, but one of them is his favorite. The king wants to split the kingdom in such a way that the area of the province that belongs to his favorite child is as large as possible. Can you help him to solve this tricky task?

입력

The first line of the input contains two integers n and m (1 ≤ n, m ≤ 1000). The following n lines contain m characters each. Each character represents one cell of the matrix. Character ‘.’ represents an empty cell, uppercase letters from ‘A’ to ‘Z’ represent the castles. Letter ‘A’ corresponds to the castle of the king’s favorite child.

All letters are different. There is exactly one letter ‘A’.

출력

Output the same matrix, replacing each character ‘.’ with the lowercase letter, corresponding to the owner of the province containing this cell.

제한

예제 입력 1

6 8
......X.
.F......
...A....
........
.....P..
..L.....

예제 출력 1

xxxxxxXx
fFaaaaaa
ffaAaaaa
ffaaaaaa
lllllPpp
llLllppp

힌트

출처

ICPC > Regionals > Northern Eurasia > Northwestern Russia Regional Contest > ICPC 2019-2020 North-Western Russia Regional Contest K번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /