#P9924. [POI 2023/2024 R1] Satelity
[POI 2023/2024 R1] Satelity
Background
Translated from XXXI Olimpiada Informatyczna - Stage I Satelity。
Problem Description
There are satellites. Satellites belong to company A, and satellites belong to company B.
Two satellites should be able to communicate if and only if they belong to the same company, or there is an additional requirement.
You need to assign each satellite a unique identification code of the same length. The code must contain only the letters ABC. Two satellites can actually communicate if and only if their codes have at least one position with the same letter. Your coding scheme must satisfy the requirements. Output your scheme.
Input Format
This problem has multiple test cases. Read until end of file.
For each test case, the first line contains three positive integers , where means the length of your identification codes must not exceed .
The next lines each contain two positive integers, meaning that these two satellites have an additional requirement and should be able to communicate.
Output Format
For each test case, the first line contains a positive integer , meaning the length of the identification codes in your scheme.
The next lines each contain a string of length consisting only of ABC, which is the identification code.
3 4 4
1 4
2 6
3 4
3 6
3
ABA
AAC
BAA
BBB
CCB
BCC
见附件
见附件
见附件
见附件
2 1 4
1 4
2
AB
AC
BA
BB
Hint
A single input file does not exceed 40MB. Please use fast input and output methods.
Constraints: for all test points, , .
For all testdata, , .
| Subtask ID | Additional Constraints | Score |
|---|---|---|
| 1 | , | 7 |
| 2 | 11 | |
| 3 | 23 | |
| 4 | 41 | |
| 5 | 18 |
Translated by ChatGPT 5