Nyoj17 monotonically incrementing longest vertex sequence (DP)
- Question 17
- Question Information
- Running result
- Rankings
- Discussion area monotonically incrementing maximum eldest son sequence time limit: 3000 MS | memory limit: 65535 KB difficulty: 4
-
Description
-
Returns the length of the longest incrementing sub-sequence of a string.
For example, the longest incremental sub-sequence of dabdbf is abdf and the length is 4.
-
Input
-
The first line is an integer of 0. <20,表示有n个字符串要处理
Next n rows, each line has a string, the length of the string will not exceed 10000 <20,表示有n个字符串要处理
-
Output
-
Length of the longest incrementing sub-sequence of the output string
-
Sample Input
-
3aaaababcabklmncdefg
-
Sample output
-
137
-
Source
-
Typical questions
-
Uploaded
-
Iphxer
Very simple DP, from the back to the back .. Easy to understand
Remember several classic DP, and all the problems in the future will come from these simple DP ..
#include
#include
#include using namespace std;int main(){char a[10001];int t,len,i,j,dp[10001];scanf(%d,&t);getchar();while(t--){gets(a);len=strlen(a);for(i=0;i
=0;i--){for(j=i+1;j