CF193C.Hamming Distance

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Hamming distance between strings aa and bb of equal length (denoted by h(a,b)h(a,b) ) is equal to the number of distinct integers ii (1<=i<=a)(1<=i<=|a|) , such that aibia_{i}≠b_{i} , where aia_{i} is the ii -th symbol of string aa , bib_{i} is the ii -th symbol of string bb . For example, the Hamming distance between strings "aba" and "bba" equals 11 , they have different first symbols. For strings "bbba" and "aaab" the Hamming distance equals 44 .

John Doe had a paper on which four strings of equal length s1s_{1} , s2s_{2} , s3s_{3} and s4s_{4} were written. Each string sis_{i} consisted only of lowercase letters "a" and "b". John found the Hamming distances between all pairs of strings he had. Then he lost the paper with the strings but he didn't lose the Hamming distances between all pairs.

Help John restore the strings; find some four strings s1s'_{1} , s2s'_{2} , s3,s4s'_{3},s'_{4} of equal length that consist only of lowercase letters "a" and "b", such that the pairwise Hamming distances between them are the same as between John's strings. More formally, set sis'_{i} must satisfy the condition .

To make the strings easier to put down on a piece of paper, you should choose among all suitable sets of strings the one that has strings of minimum length.

输入格式

The first line contains space-separated integers h(s1,s2)h(s_{1},s_{2}) , h(s1,s3)h(s_{1},s_{3}) , h(s1,s4)h(s_{1},s_{4}) . The second line contains space-separated integers h(s2,s3)h(s_{2},s_{3}) and h(s2,s4)h(s_{2},s_{4}) . The third line contains the single integer h(s3,s4)h(s_{3},s_{4}) .

All given integers h(si,sj)h(s_{i},s_{j}) are non-negative and do not exceed 10510^{5} . It is guaranteed that at least one number h(si,sj)h(s_{i},s_{j}) is positive.

输出格式

Print -1 if there's no suitable set of strings.

Otherwise print on the first line number lenlen — the length of each string. On the ii -th of the next four lines print string sis'_{i} . If there are multiple sets with the minimum length of the strings, print any of them.

输入输出样例

  • 输入#1

    4 4 4
    4 4
    4
    

    输出#1

    6
    aaaabb
    aabbaa
    bbaaaa
    bbbbbb
    
首页