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

19448번 - Dominoes 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 256 MB95201221.053%

문제

Pasha has a board of size $n \times m$. Some cells are colored black, some --- colored green, all remaining cells are colored white. Also, Pasha has a typical domino set consisting of 28 dominoes. He wants to place some of this dominoes on the board in the following way:

  • Each domino occupies exactly two neighboring cells;
  • Each non-black cell is occupied with exactly one domino;
  • There is no black cell occupied with domino;
  • The total number of dots on the green cells $g$ is maximized.

You are to write a program to find the maximum possible value of $g$ for the given board.

입력

There will be multiple test cases in the input. Each test case starts with two positive integers $n$ and $m$ (1ドル \leq n \cdot m \leq 56$). The following $n$ lines contain $m$ characters each. The $i$-th line describes the $i$-th row of the board: 'W' denotes the white cell, 'B' --- the black cell and 'G' --- the green cell. Each board contains at least one green cell. The last test case is followed by a line that contains two zeroes. It must not be processed. There will be no more than 500ドル$ test cases in the input.

출력

For each test case output its number and then the maximum value of $g$. If it is impossible to place dominoes in the described way --- output "No solution" instead. Follow the format of the sample output.

제한

예제 입력 1

4 4
GWWW
GWWB
BWWB
BWWG
1 3
WGW
0 0

예제 출력 1

Case 1: 18
Case 2: No solution

힌트

The following image shows how to place dominoes in the first sample:

출처

Camp > Petrozavodsk Programming Camp > Summer 2016 > Day 2: Pavel Khaustov Contest 2 D번

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

출처

대학교 대회

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

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