#K47327. Activity Segments

    ID: 28174 Type: Default 1000ms 256MiB

Activity Segments

Activity Segments

You are given t strings representing the activity logs of t users. Each string consists of characters 'A' and 'I', where 'A' denotes an active state and 'I' denotes an inactive state. For each string, your task is to compute the lengths of consecutive segments of identical characters. The output for each string should be the sequence of segment lengths separated by a space.

For example, given a user log AAAIIIIA, the segments are: AAA (length 3), IIII (length 4), A (length 1). Therefore, the output is 3 4 1.

Note: All formulas and mathematical notations are written in LaTeX format when necessary. In this problem, if any expression is needed it should appear as \(expression\).

inputFormat

The first line contains an integer \(t\) representing the number of users. The following \(t\) lines each contain a string composed of the characters 'A' and 'I', representing the activity log for each user.

For example:

3
AAAIIIIA
AIAIAI
AAAAA

outputFormat

Output \(t\) lines, where each line contains the lengths of consecutive segments for the corresponding user's activity log, separated by a space.

For example, the corresponding output for the above sample would be:

3 4 1
1 1 1 1 1 1
5
## sample
3
AAAIIIIA
AIAIAI
AAAAA
3 4 1

1 1 1 1 1 1 5

</p>