/* ***********************************************author:maltubemail: [email Protected]blog: htttp://www.xiang578.com************************************************ * *#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <vector>#include <queue>#include <set>#include <map>#include <string>#include <math.h>#include <stdlib.h>#include <time.h>//#include <bits/stdc++.h>#define REP (i,a,n) for (int i=a;i<n;i++)#define PER (i,a,n) for (int i=n-1;i>=a;i--)#define PB Push_backusing namespace STD;typedef vector<int>VI;typedef Long LongllConstll mod=1000000007;Const intn=2048;Chars[100000+Ten];intdp[10000+Ten][5]; Map<string,int>mp vector<string>VintLenintGetintStintL) {stringT1,T2,T3;if(St+l>len)return 0;Else if(St+l==len) { for(intI=0; i<l; i++) T1+=s[st+i];if(mp[t1]==0) {mp[t1]++; V.push_back (t1); } }Else{intf=0, S2=st+l; for(intI=0; i<l; i++) T1+=s[st+i]; for(intI=0;i<2; i++) T2+=s[s2+i]; for(intI=0;i<3; i++) T3+=s[s2+i];if(l==2) {if(t1!=t2&&dp[s2][2]) f=1;if(dp[s2][3]) f=1; }Else if(l==3) {if(t1!=t3&&dp[s2][3]) f=1;if(dp[s2][2]) f=1; }if(f==0)return 0;if(mp[t1]==0) {mp[t1]++; V.push_back (t1); } }return 1;}intMain () {//freopen ("In.txt", "R", stdin); //freopen ("OUT.txt", "w", stdout); memset(S,0,sizeof(s));scanf('%s ', s); V.clear (); Mp.clear ();memset(DP,0,sizeof(DP)); len=strlen(s); for(inti=len-1; i>=5; i--) {dp[i][2]=get (I,2); dp[i][3]=get (I,3); } sort (V.begin (), V.end ());printf("%d\n", V.size ()); for(intI=0; I<v.size (); i++) {cout<<v[i]<<endl; }return 0;}
Codeforces Round #349 (Div. 2) C. Reberland Linguistics "DP"