$dp$。

题意中有一个词组:$in$ $a$ $row$,是连续的意思....

因此这题只要倒着$dp$一下就可以了。$f[i][0]$表示从$i$位置往后割两个能否割,$f[i][1]$表示从$i$位置往后割三个能否割。

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<iostream>
using namespace std;
typedef long long LL;
const double pi=acos(-1.0),eps=1e-;
void File()
{
freopen("D:\\in.txt","r",stdin);
freopen("D:\\out.txt","w",stdout);
}
template <class T>
inline void read(T &x)
{
char c=getchar(); x=;
while(!isdigit(c)) c=getchar();
while(isdigit(c)) {x=x*+c-''; c=getchar();}
} const int maxn=;
char s[maxn];
int len,f[maxn][];
vector<string>ans;
map<string,bool>d; int main()
{
memset(s,,sizeof s);
scanf("%s",s); len=strlen(s);
f[len][]=f[len][]=;
for(int i=len-;i>;i--)
{
if(len-i>=)
{
if(f[i+][]==)
{
char t[]; memset(t,,sizeof t);
t[]=s[i]; t[]=s[i+]; f[i][]=;
if(d[t]==) ans.push_back(t),d[t]=;
}
else if(f[i+][]==)
{
char t[],g[]; memset(t,,sizeof t); memset(g,,sizeof g);
t[]=s[i]; t[]=s[i+]; g[]=s[i+]; g[]=s[i+]; if(strcmp(t,g)==) continue;
f[i][]=;
if(d[t]==) ans.push_back(t),d[t]=;
}
}
if(len-i>=)
{
if(f[i+][]==)
{
char t[]; memset(t,,sizeof t);
t[]=s[i]; t[]=s[i+]; t[]=s[i+]; f[i][]=;
if(d[t]==) ans.push_back(t),d[t]=;
} else if(f[i+][]==)
{
char t[],g[]; memset(t,,sizeof t); memset(g,,sizeof g);
t[]=s[i]; t[]=s[i+]; t[]=s[i+];
g[]=s[i+]; g[]=s[i+]; g[]=s[i+]; if(strcmp(t,g)==) continue;
f[i][]=;
if(d[t]==) ans.push_back(t),d[t]=;
}
}
}
sort(ans.begin(),ans.end());
printf("%d\n",ans.size());
for(int i=;i<ans.size();i++) cout<<ans[i]<<endl;
return ;
}

CodeForces 667C Reberland Linguistics的更多相关文章

  1. Codeforces 667C Reberland Linguistics 记忆化搜索

    链接 Codeforces 667C Reberland Linguistics 题意 给你一个字符串,除去前5个字符串后,使剩下的串有长度为2或3的词根组成,相邻的词根不能重复.找到所有的词根 思路 ...

  2. Codeforces 667C Reberland Linguistics【DFS】

    一道卡题意的题. 题目链接: http://codeforces.com/problemset/problem/667/C 题意: 一个串可以看成一个长度大于4的根,加上其后面的若干个相邻(in a ...

  3. CodeForces 666A Reberland Linguistics(DP)

    A. Reberland Linguistics time limit per test 1 second memory limit per test 256 megabytes input stan ...

  4. Codeforces.666A.Reberland Linguistics(DP)

    题目链接 \(Description\) 给定串s,其由一个基本串后加任意多个长度为2或3的后缀串构成,要求基本串长度>4且相邻后缀串不相同.在基本串任意确定的情况下,求所有可能的后缀串. \( ...

  5. codeforces 667C C. Reberland Linguistics(dp)

    题目链接: C. Reberland Linguistics time limit per test 1 second memory limit per test 256 megabytes inpu ...

  6. Codeforces Round #349 (Div. 1) A. Reberland Linguistics 动态规划

    A. Reberland Linguistics 题目连接: http://www.codeforces.com/contest/666/problem/A Description First-rat ...

  7. Codeforces Round #349 (Div. 1) A. Reberland Linguistics dp

    题目链接: 题目 A. Reberland Linguistics time limit per test:1 second memory limit per test:256 megabytes 问 ...

  8. Codeforces Round #349 (Div. 2) C. Reberland Linguistics (DP)

    C. Reberland Linguistics time limit per test 1 second memory limit per test 256 megabytes input stan ...

  9. Codeforces Round #349 (Div. 2) C. Reberland Linguistics DP+set

    C. Reberland Linguistics     First-rate specialists graduate from Berland State Institute of Peace a ...

随机推荐

  1. canvas 之刮刮卡

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  2. HTTP method GET is not supported by this URL(转)

    源地址:http://blog.csdn.net/qfs_v/article/details/2545168 Servlet  eroor:HTTP method GET is not support ...

  3. 关于Grunt可视化的尝试

    关于Grunt可视化的尝试 使用Grunt遇到的问题? 必须要安装NodeJS 必须安装grunt-cli 需要编写复杂的Gruntfile.js规则 每个项目中必须存在nodejs的grunt模块 ...

  4. Oracle和Mysql分别生成sequence序列

    有时候在往数据库中插入数据的时候,如果ID值是32位的UUID, 而自己随便写个字符又不合适,这时就要用到函数来产生一个序列值 Oracle: select sys_guid() from dual; ...

  5. Makefile常用信息查询页

    这是博主第一次尝试在博客中使用markdown来写博文,目前感觉还不错.大家也可以尝试尝试. 符号说明 符号 作用   换行符 @ 放在命令前面隐藏命令输出 - 放在命令前面忽略命令错误 : 以来规则 ...

  6. 如何简单而优雅地升级Visual NMP中的PHP版本

    需求:自己想测试下不同版本的PHP性能,就想升级下 Visual 这个集成环境中PHP的版本 网上: 升级PHP到5.6.11 1.下载新的nts版的PHP并解压缩到bin\PHP下,保留原文件夹的名 ...

  7. ASP.NET MVC学习笔记-----Filter2

    ASP.NET MVC学习笔记-----Filter(2) 接上篇ASP.NET MVC学习笔记-----Filter(1) Action Filter Action Filter可以基于任何目的使用 ...

  8. json-smart 使用示例

    json-smart 使用示例 json是一种通用的数据格式.相比与protocal buffer.thrift等数据格式,json具有可读性强(文本).天生具备良好的扩展性(随意增减字段)等优良特点 ...

  9. Closures in OOC

    Closures in OOC 接上一篇Complexity Behind Closure,这次来专注于Rock是如何在C里实现Closure的. 这篇文章同时发布在Github上. Block as ...

  10. J2EE (九) 静态代理和动态代理--间接“美”

    生活中有很多例子是间接来控制和访问的,比如你找一个人不自己亲自去,而是让别人代替去做这就是最简单的代理模式,是一种间接通信的例子,对象间的间接通信也同样是面向对象设计中的一条重要的“审美观”.间接通信 ...