#K82082. Unlockable Sequence
Unlockable Sequence
Unlockable Sequence
You are given a sequence of strings. Your task is to determine whether the sequence is unlockable. A sequence is defined to be unlockable if every string in the sequence is a permutation of the others.
In other words, given a sequence of strings \( S_1, S_2, \dots, S_N \), the sequence is unlockable if and only if
[ \text{sort}(S_1) = \text{sort}(S_2) = \dots = \text{sort}(S_N), ]
where \( \text{sort}(S) \) denotes the string obtained by sorting the characters of \( S \) in non-decreasing order.
Determine whether the given lock sequence is unlockable.
inputFormat
The input is read from standard input (stdin
) and is formatted as follows:
T N1 string11 string12 ... string1N1 N2 string21 string22 ... string2N2 ... NT stringT1 stringT2 ... stringTNT
Here, the first line contains an integer T
representing the number of test cases. For each test case, the first line contains an integer N
indicating the number of strings, followed by N
lines each containing a single string.
outputFormat
For each test case, output a single line to standard output (stdout
) with either Unlockable
or Not Unlockable
depending on whether the sequence meets the criteria.
1
3
123
321
312
Unlockable
</p>