monotonically increasing the eldest-son sequenceTime limit: Ms | Memory limit: 65535 KB Difficulty: 4 describes the length of the longest incrementing subsequence of a string
such as: dabdbf the longest increment subsequence is ABDF, the length is 4 input the first line an integer 0<n<20, indicating that there are n strings to be processed
The next n rows, each line has a string that does not exceed the length of the longest increment subsequence of the 10000 output string for the sample input
3
AAA
ababc
ABKLMNCDEFG
Sample output
1
3
7
Source
Classic Topics
/*********************************
* Date: 2013-3-25
* Author: SJF0115
* title: Title 17: monotonically increasing the eldest son sequence
* Source: http://acm.nyist.net/JudgeOnline/problem.php?pid=17
* Result: AC
* Source: Nanyang Polytechnic OJ
* Summary:
**********************************/
#include <stdio.h>
#include <string.h>
Char array[10001];
int maxlen[10001];
Maximum increment subsequence
void LIS () {memset (
maxlen,0,sizeof (MaxLen));
int len = strlen (array);
for (int i = 0;i < len;i++) {
maxlen[i] = 1;
for (int j = 0;j < i;j++) {
if (Array[i] > Array[j]) {
if (Maxlen[i] < 1 + maxlen[j]) {
Maxlen[i] = 1 + MAXLEN[J]
;
}}}} int main ()
{
int n,i,len,max;
Freopen ("C:\\users\\sjf\\desktop\\acm.txt", "R", stdin);
scanf ("%d", &n);
N set of test data
while (n--) {
Max = 0;
scanf ("%s", array);
LIS ();
Len = strlen (array);
Output maximum length for
(i = 0;i < len;i++) {
if (Max < maxlen[i]) {
max = maxlen[i];
}
}
printf ("%d\n", Max);
}
return 0;
}
Specific reference: Click to open the link