Title Description
The length of the longest increment subsequence of a string, such as: dabdbf the longest increment subsequence is abdf, length is 4
Enter a description
The first line is an integer 0<n<20, which indicates that there are n strings to process, followed by n rows, each line has a string, and the length of the string does not exceed 10000
Output description
The length of the longest increment subsequence of the output string
Input sample
3 AAAABABCABKLMNCDEFG
Output sample
1 3 7
Test code
1#include <stdio.h>2#include <string.h>3 #defineN 100104 5 CharStr[n];6 intMaxlen[n];7 intMainvoid)8 {9 intN, Len, I, J, Max;Ten Onescanf"%d", &n); A GetChar (); - while(n--) - { the fgets (str, N, stdin); -Len =strlen (str); -maxlen[0] =1; - for(i =1; i < Len; i++) + { -Max =0; + for(j = i-1; J >=0; j--) A { at if(Str[i] > Str[j] && Max <Maxlen[j]) - { -Max =Maxlen[j]; - } - } -Maxlen[i] = max +1; in } -max = maxlen[0]; to for(i =1; i < Len; i++) + { -Max = (Maxlen[i] > max)?Maxlen[i]: max; the } *printf"%d\n", max); $ }Panax Notoginseng return 0; -}
monotonically increasing the eldest-son sequence