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

15515번 - Tap Titanz at Moloco (Hard) 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB112625764.045%

문제

Some Moloco employees play clicker games like 'Tap Titanz'.

In Tap Titanz, a player is given an n-by-n chessboard whose cells are either black or white. Two cells are said to be adjacent if they share an edge. We say that two cells are connected if there is a path from one cell to the other consisting only of adjacent cells of the same color (hence the two cells must be of the same color).

When the player taps on one of the cells, the tap changes the color of the cell being tapped on as well as its adjacent cells of the same color, and their adjacent cells of the same color, and so on. More formally, if the player taps on a cell, the cell and all the other cells to which it is connected will have their color changed instantly.

The goal of this game is to tap as few times as possible, while making all cells to have the same color (either black or white).

입력

The first line contains an integer n between 1 and 25, inclusive.

The following n lines describe the chessboard where i+1th row contains a string of length n that describes the ith row of the chessboard. Each string consists only of 'B' or 'W' for Black or White denoting the color of a cell.

출력

Your output should contain a single integer which is the minimum number of taps required to make all cells to have the same color.

제한

예제 입력 1

3
BWB
WBW
WWW

예제 출력 1

2

힌트

출처

Contest > Startlink Online Contest > Startlink Online Contest #1 D2번

  • 문제를 만든 사람: haden
  • 데이터를 추가한 사람: doju, lyzqm
(追記) (追記ここまで)

출처

대학교 대회

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

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