Codeforces Round #349 (Div. 2) C. Reberland Linguistics 【DP】
来源:互联网 发布:程序员技术博客 编辑:程序博客网 时间:2024/06/03 21:47
/* ***********************************************Author :MaltubEmail :xiang578@foxmail.comBlog :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 long ll;const ll mod=1000000007;const int N=2048;char s[100000+10];int dp[10000+10][5];map<string,int>mp;vector<string>v;int len;int get(int st,int l){ string t1,t2,t3; if(st+l>len) return 0; else if(st+l==len) { for(int i=0; i<l; i++) t1+=s[st+i]; if(mp[t1]==0) { mp[t1]++; v.push_back(t1); } } else { int f=0,s2=st+l; for(int i=0; i<l; i++) t1+=s[st+i]; for(int i=0;i<2;i++) t2+=s[s2+i]; for(int i=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;}int main(){ //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(int i=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(int i=0; i<v.size(); i++) { cout<<v[i]<<endl; } return 0;}
0 0
- Codeforces Round #349 (Div. 2) C. Reberland Linguistics 【DP】
- Codeforces Round #349 (Div. 2) C. Reberland Linguistics DP
- Codeforces Round #349 (Div. 2) C. Reberland Linguistics
- Codeforces Round #349 (Div. 1) A. Reberland Linguistics 动态规划
- Codeforces 667C Reberland Linguistics (DP)
- Codeforces 667C Reberland Linguistics 【dp】
- Codeforces 667C Reberland Linguistics dp+set
- Codeforces 667C Reberland Linguistics 【dp】
- 667C - Reberland Linguistics【dp】
- CodeForces 666A Reberland Linguistics(DP)
- CodeForces 666A. Reberland Linguistics【DP】
- Codeforces 667C Reberland Linguistics【DFS】
- 【16.67%】【codeforces 667C】Reberland Linguistics
- Codeforces #349 Div2 C Reberland Linguistics(twice in a row)
- codeforces_667C. Reberland Linguistics(dp+set)
- Codeforces #349 div1 A. Reberland Linguistics 模拟 递推
- 【DP】Codeforces Round #336 (Div. 2) C
- Codeforces Round #363 (Div. 2) C dp
- uboot中语句__asm__ __volatile__("": : :"memory");理解
- 借助WinDriver认识Windows PCIE设备的空间结构
- iOS 网络编程之TCP/IP <二> 框架的二次封装
- POJ 3618
- leetcode.304. Range Sum Query 2D - Immutable
- Codeforces Round #349 (Div. 2) C. Reberland Linguistics 【DP】
- dom4j回车换行符(给群中朋友需要解决的基础写的乱看看就行)
- iOS7.0导航栏设置
- stristr_strrchr.php
- java 资源获取
- 保存数据报错Write operations are not allowed in read-only mode (FlushMode.MANUAL)
- ApplicationInfo的flags属性
- android官方自带下拉刷新功能
- android 使用ffmpeg