#P10296. [CCC 2024 S2] Heavy-Light Composition

[CCC 2024 S2] Heavy-Light Composition

Problem Description

In a string that contains only lowercase letters, a letter is called heavy if and only if it appears more than once in the string; otherwise, it is called light.

Given some strings, for each string, determine whether the heavy letters and light letters appear alternately. (That is, either every letter in an odd position is heavy and every letter in an even position is light, or every letter in an odd position is light and every letter in an even position is heavy.)

Input Format

The first line contains two positive integers TT and NN, representing the number of strings and the length of each string.

The next TT lines each contain a string of length NN consisting of lowercase letters.

Output Format

Output TT lines, each containing a single character T or F. If in the ii-th input string, the light letters and heavy letters appear alternately, output T on the ii-th line; otherwise, output F.

3 4
abcb
bcbb
babc

T
F
T

2 3
abc
bcb

F
T

Hint

[Sample 1 Explanation]

The first string consists of light, heavy, light, heavy letters.

The second string ends with two consecutive heavy letters.

The third string consists of heavy, light, heavy, light letters.

[Sample 2 Explanation]

The first string consists entirely of light letters.

The second string consists of heavy, light, heavy letters.

[Constraints]

This problem uses bundled testdata.

For all testdata, the strings are guaranteed to contain only lowercase letters, 2T1042\leq T\leq 10^4, and 2N1002\leq N\leq 100.

The table below shows the allocation of the 1515 points:

Points Range of TT Range of NN Other Constraints
55 2T42 \leq T \leq 4 2N42 \leq N \leq 4 The strings contain only a and b.
2T102 \leq T \leq 10 2N302 \leq N \leq 30 None.
22 2T1002 \leq T \leq 100 2N1002 \leq N \leq 100 Only the letter a is heavy; other letters are light.
33 2T1042 \leq T \leq 10^4 None.

Translated by ChatGPT 5