Nyoj 17 monotonically incrementing the eldest son sequence DP

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.