Consider a text with n characters. The characters used in the text are lower case English alphabet letters and the character *. Two words in the text are separated by one or more * characters.
Task
a) Determine the positions in the text of words that contain a maximum length sequence comprised of letters in strictly ascending alphabetical order.
b) Letters from this text are used to mark with letters the vertices of a regular
polygon. The same letter cannot be used for marking two different vertices of
a polygon. For the given text determine the maximum number of vertices of a
regular polygon that can be marked using these letters.
Input data
Input
file text.in contains on the
first line the positive integer n,
and on the second line the text characters without any spaces between them.
Output data
Output file
text.out will contain on the
first line the number of words with the property from point a). The second line
will contain the positions of words with the property from point a), in ascending
order, any two consecutive positions being separated by a space. The third line
will contain the number requested in point b).
Constraints
text.in | text.out | Explanation |
40 abcdayz***abcabcdey**pqrs**mnpqruab**aba |
2 |
At point a) we have words abcabcdey and mnpqruab on positions 2 and 4 which contain strictly ascending sequences of maximum length abcdey, and respectively mnpqru. |
Time limit: 0.1 seconds/test
prof. Doru Popescu Anastasiu
"Radu Greceanu" National College - Slatina
Contact:dopopan@yahoo.com