UVA 115,841 Partitioning by palindromes

Source: Internet
Author: User

Partitioning by palindromes

Time Limit: 1000MS Memory Limit:0KB 64bit IO Format:%lld &%llu

SubmitStatusPracticeUVA 11584
1#include <stdio.h>2#include <string.h>3#include <algorithm>4 using namespacestd;5 6 Chara[1005];7 8 intCintXinty)9 {Ten     intflg=1; One      while(x<y) A     { -         if(a[x]!=A[y]) -         { theflg=0; -              Break; -         } -x++,y--; +     } -     returnFLG; + } A  at intMain () - { -     intT; -     intdp[1005]; -scanf"%d",&T); -      while(t--) in     { -         intn,i,j; toscanf"%s", a); +Memset (DP,0,sizeof(DP)); -n=strlen (a); thedp[0]=1; *          for(i=1; i<n;i++) $         {Panax Notoginsengdp[i]=dp[i-1]+1; -              for(j=i-1;j>0; j--) the             { +                 if(C (j,i)) A                 { theDp[i]=min (dp[i],dp[j-1]+1); +                 } -             } $             ifC0, i)) $dp[i]=1; -         } -         /*For (i=0;i<n;i++) the printf ("%d", Dp[i]); - printf ("\ n");*/Wuyiprintf"%d\n", dp[n-1]); the     } -     return 0; Wu}
View Code

UVA 115,841 Partitioning by palindromes

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.