#P1341. 无序字母对
无序字母对
Description
Given distinct unordered letter pairs (case-sensitive; unordered means the two letters in a pair can appear in either order), construct a string with letters such that each letter pair appears in this string.
Input Format
The first line contains a positive integer .
Each of the next lines contains two letters, indicating that these two letters must be adjacent.
Output Format
Output a string that satisfies the requirement.
If no such string exists, output No Solution.
If multiple solutions exist, output the lexicographically smallest one (i.e., the earlier letters should have smaller ASCII codes).
4
aZ
tZ
Xt
aX
XaZtX
Hint
The number of different unordered letter pairs is finite, and the scale of can be calculated.
Translated by ChatGPT 5
京公网安备 11011102002149号