O-Chequered Flag
On their favorite subject: painting, Miloš, Filip i Milan just get a extra task to pass exam. For the incoming race over Sombor town, big chequered flag is about to be made. Flag will be R by C dimensioned, as on all car racing flag is made of square black and white units. No budget for this job, only old parts of wrong painted flags by previous generation.
After they finished flag, big surprise come. Flag is not colored as needed. Goal is to paint flag in such way that no neighbors units of same color (neighbors are next four fields: left, right, up or down, border units has three neighbors and corner units just two).
Remaining job is only painting this flag in proper color. Condition that make this exam passed are to use as minimum color as possible.
], number of rows and columns on flag (1 <= R,C <= 3000).
Next R rows contain C characters ’C’ or ’B’ (no space between).[c]3 3
CCC
CCC
CCC
Output:
4
3 4
CBCB
BCBC
CBCBOutput:
0
4 2
BC
BC
CB
BCOutput:
2
NOTICE: no meter whether left up square unit of flag is white or black.
Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.