Codeforces Beta Round 93 (Div. 1 Only)
E
Pills
Codeforces
2900
原题
← D→
翻译中…

Doctor prescribed medicine to his patient. The medicine is represented by pills. Each pill consists of a shell and healing powder. The shell consists of two halves; each half has one of four colors — blue, red, white or yellow.

翻译中…

The doctor wants to put $28$ pills in a rectangular box $7 × 8$ in size. Besides, each pill occupies exactly two neighboring cells and any cell contains exactly one half of a pill. Thus, the result is a four colored picture $7 × 8$ in size.

翻译中…

The doctor thinks that a patient will recover sooner if the picture made by the pills will be special. Unfortunately, putting the pills in the box so as to get the required picture is not a very easy task. That's why doctor asks you to help.

翻译中…

Doctor has some amount of pills of each of $10$ painting types. They all contain the same medicine, that's why it doesn't matter which $28$ of them will be stored inside the box.

翻译中…

Place the pills in the box so that the required picture was formed. If it is impossible to place the pills in the required manner, then place them so that the number of matching colors in all $56$ cells in the final arrangement and the doctor's picture were maximum.

翻译中…

Input

翻译中…

First $7$ lines contain the doctor's picture. Each line contains $8$ characters, each character can be "B", "R", "W" and "Y" that stands for blue, red, white and yellow colors correspondingly.

翻译中…

Next four lines contain $10$ numbers that stand for, correspondingly, the number of pills painted:

翻译中…

"BY" "BW" "BR" "BB"

翻译中…

"RY" "RW" "RR"

翻译中…

"WY" "WW"

翻译中…

"YY"

翻译中…

Those numbers lie within range from $0$ to $28$ inclusively. It is guaranteed that the total number of pills in no less than $28$.

翻译中…

Output

翻译中…

Print on the first line the maximal number cells for which the colors match.

翻译中…

Then print $13$ lines each containing $15$ characters — the pills' position in the optimal arrangement. The intersections of odd lines and odd columns should contain characters "B", "R", "W" and "Y". All other positions should contain characters ".", "-" and "|". Use "-" and "|" to show which halves belong to one pill. See the samples for more clarification.

翻译中…

If there are several possible solutions, print any of them.

翻译中…

样例

Input #1
WWWBBWWW
WWWBBWWW
YYWBBWWW
YYWBBWRR
YYWBBWRR
YYWBBWRR
YYWBBWRR
0 0 0 8
0 1 5
1 10
5
Output #1
53
W.W.W.B.B.W.W.W
|.|.|.|.|.|.|.|
W.W.W.B.B.W.W.W
...............
Y.Y.W.B.B.W.W-W
|.|.|.|.|.|....
Y.Y.W.B.B.W.R.R
............|.|
Y.Y.W.B.B.R.R.R
|.|.|.|.|.|....
Y.Y.W.B.B.W.R.R
............|.|
Y-Y.B-B.B-B.R.R
InputCopy OutputCopy
Input #2
WWWWWWWW
WBYWRBBY
BRYRBWYY
WWBRYWBB
BWWRWBYW
RBWRBWYY
WWWWWWWW
0 0 0 1
0 0 1
0 1
25
Output #2
15
W.Y.Y-Y.Y-Y.Y-Y
|.|............
W.Y.Y.Y.Y.B-B.Y
....|.|.|.....|
Y-Y.Y.Y.Y.Y-Y.Y
...............
Y.Y.Y.R.Y.Y.Y-Y
|.|.|.|.|.|....
Y.Y.Y.R.Y.Y.Y.Y
............|.|
Y-Y.Y.Y-Y.Y.Y.Y
....|.....|....
Y-Y.Y.Y-Y.Y.Y-Y
InputCopy OutputCopy
题目信息
题号
126E
时间限制
1.5 s
内存限制
256 MB
标签
暴力
网络流

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。