CF142C.Help Caretaker

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Autumn came late to the kingdom of Far Far Away. The harvest was exuberant and it is now time to get ready for the winter. As most people celebrate the Harvest festival, Simon the Caretaker tries to solve a very non-trivial task of how to find place for the agricultural equipment in the warehouse.

He's got problems with some particularly large piece of equipment, which is, of course, turboplows. The problem is that when a turboplow is stored, it takes up not some simply rectangular space. It takes up a T-shaped space like on one of the four pictures below (here character "#" stands for the space occupied by the turboplow and character "." stands for the free space):

### ..# .#. #..<br></br>.#. ### .#. ###<br></br>.#. ..# ### #..<br></br> Simon faced a quite natural challenge: placing in the given n×mn×m cells warehouse the maximum number of turboplows. As one stores the turboplows, he can rotate them in any manner (so that they take up the space like on one of the four pictures above). However, two turboplows cannot "overlap", that is, they cannot share the same cell in the warehouse.

Simon feels that he alone cannot find the optimal way of positioning the plugs in the warehouse that would maximize their quantity. Can you help him?

输入格式

The only line contains two space-separated integers nn and mm — the sizes of the warehouse ( 1<=n,m<=91<=n,m<=9 ).

输出格式

In the first line print the maximum number of turboplows that can be positioned in the warehouse. In each of the next nn lines print mm characters. Use "." (dot) to mark empty space and use successive capital Latin letters ("A" for the first turboplow, "B" for the second one and so on until you reach the number of turboplows in your scheme) to mark place for the corresponding turboplows considering that they are positioned in the optimal manner in the warehouse. The order in which you number places for the turboplows does not matter. If there are several optimal solutions for a warehouse of the given size, print any of them.

输入输出样例

  • 输入#1

    3 3
    

    输出#1

    1
    AAA
    .A.
    .A.
    
  • 输入#2

    5 6
    

    输出#2

    4
    A..C..
    AAAC..
    ABCCCD
    .B.DDD
    BBB..D
    
  • 输入#3

    2 2
    

    输出#3

    0
    ..
    ..
    
首页