CF63D.Dividing Island

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

A revolution took place on the Buka Island. New government replaced the old one. The new government includes nn parties and each of them is entitled to some part of the island according to their contribution to the revolution. However, they can't divide the island.

The island can be conventionally represented as two rectangles a×ba×b and c×dc×d unit squares in size correspondingly. The rectangles are located close to each other. At that, one of the sides with the length of aa and one of the sides with the length of cc lie on one line. You can see this in more details on the picture.

The ii -th party is entitled to a part of the island equal to xix_{i} unit squares. Every such part should fully cover several squares of the island (it is not allowed to cover the squares partially) and be a connected figure. A "connected figure" presupposes that from any square of this party one can move to any other square of the same party moving through edge-adjacent squares also belonging to that party.

Your task is to divide the island between parties.

输入格式

The first line contains 5 space-separated integers — aa , bb , cc , dd and nn ( 1<=a,b,c,d<=501<=a,b,c,d<=50 , bdb≠d , 1<=n<=261<=n<=26 ). The second line contains nn space-separated numbers. The ii -th of them is equal to number xix_{i} ( 1<=xi<=a×b+c×d1<=x_{i}<=a×b+c×d ). It is guaranteed that .

输出格式

If dividing the island between parties in the required manner is impossible, print "NO" (without the quotes). Otherwise, print "YES" (also without the quotes) and, starting from the next line, print max(b,d)max(b,d) lines each containing a+ca+c characters. To mark what square should belong to what party, use lowercase Latin letters. For the party that is first in order in the input data, use "a", for the second one use "b" and so on. Use "." for the squares that belong to the sea. The first symbol of the second line of the output data should correspond to the square that belongs to the rectangle a×ba×b . The last symbol of the second line should correspond to the square that belongs to the rectangle c×dc×d .

If there are several solutions output any.

输入输出样例

  • 输入#1

    3 4 2 2 3
    5 8 3
    

    输出#1

    YES
    aaabb
    aabbb
    cbb..
    ccb..
    
  • 输入#2

    3 2 1 4 4
    1 2 3 4
    

    输出#2

    YES
    abbd
    cccd
    ...d
    ...d
    
首页