题库练习 Toys
← 上一题 下一题 →

A15055 | Toys

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

Vittorio has three favorite toys: a teddy bear, an owl, and a raccoon. Each of them has a name.

Vittorio takes several sheets of paper and writes a letter on each side of every sheet so that it is possible to spell any of the three names by arranging some of the sheets in a row (sheets can be reordered and flipped as needed). The three names do not have to be spelled at the same time, it is sufficient that it is possible to spell each of them using all the available sheets (and the same sheet can be used to spell different names).

Find the minimum number of sheets required. In addition, produce a list of sheets with minimum cardinality which can be used to spell the three names (if there are multiple answers, print any).

输入格式

The first line contains a string $t$ consisting of uppercase letters of the English alphabet ( $1\le |t| \le 1000$ ) — the name of the teddy bear.

The second line contains a string $o$ consisting of uppercase letters of the English alphabet ( $1\le |o| \le 1000$ ) — the name of the owl.

The third line contains a string $r$ consisting of uppercase letters of the English alphabet ( $1\le |r| \le 1000$ ) — the name of the raccoon.

The values $|t|$ , $|o|$ , $|r|$ denote the length of the three names $t$ , $o$ , $r$ .

输出格式

The first line of the output contains a single integer $m$ — the minimum number of sheets required.

Then $m$ lines follow: the $j$ -th of these lines contains a string of two uppercase letters of the English alphabet — the letters appearing on the two sides of the $j$ -th sheet.

Note that you can print the sheets and the two letters of each sheet in any order.

输入输出样例

输入 #1
AA
GA
MA
输出 #1
2
AG
AM
输入 #2
TEDDY
HEDWIG
RACCOON
输出 #2
8
AT
CH
CY
DG
DO
ER
IN
OW
输入 #3
BDC
CAA
CE
输出 #3
4
AD
AE
BB
CC
C++ 编辑器
输入
输出