monotonically increasing the oldest sequence time limit: theMs | Memory Limit:65535KB Difficulty:4
-
-
Describe
-
The length of the longest increment subsequence of a string
For example: dabdbf maximum increment subsequence is ABDF, length is 4
-
-
Input
-
-
The first line is an integer 0<n<20, which indicates that there are n strings to handle
The next n rows, each line has a string that is no longer than 10000
-
-
Output
-
The
-
length of the longest increment subsequence of the output string
-
-
Sample input
-
-
3aaaababcabklmncdefg
-
-
Sample output
-
-
137
-
-
Source
Classic Topics
#include <cstdio> #define N 10001int Main () {int Dp[n];char s[n];int t;scanf ("%d", &t), while (t--) {int ans = 0;sca NF ("%s", s); for (int i = 0; s[i]! = ' "; i++) {Dp[i] = 1;for (int j = 0; J < i; J + +) {if (S[i]>s[j] && Dp[i] < Dp[j] + 1) {Dp[i] = Dp[j] + 1;}} if (ans < dp[i]) ans = dp[i];} printf ("%d\n", ans);} return 0;}
Nyoj 17 monotonically incrementing the eldest son sequence DP