Hdu 2144 Evolution (Ji +DP)

Source: Internet
Author: User

Preprocess the data first. Similar to the request LCS

And then check the set

1#include <iostream>2#include <cstdio>3#include <cstdlib>4#include <cstring>5#include <string>6#include <queue>7#include <algorithm>8#include <map>9#include <iomanip>Ten#include <climits> One#include <string.h> A#include <cmath> -#include <stdlib.h> -#include <vector> the#include <stack> -#include <string.h> -#include <Set> - #defineINF 1e7 + #defineMAXN 10010 - #defineMAXN 1000010 + #defineMod 1000007 A #defineN 110 at using namespacestd; -typedefLong LongLL; -  - intN; - Doublem; - CharStr[n][n]; in intFa[n], len[n], dp[n][n]; -  to intFindset (intx) + { -     returnFA[X] = fa[x] = = x?X:findset (fa[x]); the } *  $ intGetlen (intAintb)Panax Notoginseng { -     intRe =0; thememset (dp[0],0,sizeof(dp[0])); +      for(inti =1; I <= Len[a]; i++) A     { thedp[i][0] =0; +          for(intj =1; J <= Len[b]; J + +) -         { $             if(Str[a][i] = = Str[b][j]) dp[i][j] = dp[i-1][j-1] +1; $             ElseDP[I][J] =0; -             if(Re < dp[i][j]) Re =Dp[i][j]; -         } the     } -     returnre;Wuyi } the intMain () - { Wu     intT =1; -     intx, Y, L; About      while(Cin >> N >>m) $     { -          for(inti =0; I < n; i++) -Fa[i] =i; -          for(inti =0; I < n; i++) A         { +scanf"%s", Str[i] +1); thestr[i][0] =' '; -Len[i] = strlen (Str[i])-1; $              for(intj =0; J < I; J + +) the             { the                 intx =Findset (i); the                 inty =Findset (j); the                 if(x = = y)Continue; -L =Getlen (i, j); in                 if(l*100.0/len[i] > M && l*100.0/LEN[J] >m) theFA[X] =y; the             } About         } the         intAns =0; the          for(inti =0; I < n; i++)if(Fa[i] = = i) ans++; theprintf"Case %d:\n%d\n", t++, ans); +     } -     return 0; the}

Hdu 2144 Evolution (Ji +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.