$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. IOS开发小功能2:二维码扫描界面的设计(横线上下移动)

    效果图如上,实现的是一个二维码扫描界面. 下面我贴出线条上下移动的代码,至于二维码的代码是用的第三方库. 首先是整体的结构: 注意下面的库文件一个都不能少,否则会报错. TLTiltHighlight ...

  2. URLDecoder: Incomplete trailing escape (%) pattern

    在使用URLDecoder对字符串进行解码的时候 报以下异常信息: Exception in thread "main" java.lang.IllegalArgumentExce ...

  3. CodeBlocks的下载安装、配置、简单编程

    CodeBlocks的下载安装.配置.简单编程 IDE简介 http://www.baidu.com/s?wd=codeblocks ,这里只是介绍Windows平台下的IDE环境配置. CodeBl ...

  4. vs2013安装xna4.0模板

    首先需要安装Windows Phone SDK 7.1,这里面包含了最新的XNA SDK,当然也能安装其它的XNA SDK. 安装完后复制模板 xcopy /e "C:\Program Fi ...

  5. Java笔记:枚举类

    1.一个类的实例是有限且固定的,这个类称为枚举类.比如季节类,只有四个对象(春.夏.秋.冬) 2.手动实现一个枚举类(1)通过private将构造器隐藏起来(2)把这个类的所有可能实例都使用priva ...

  6. 解决URL中文乱码问题--对中文进行加密、解密处理

    解决URL中文乱码问题--对中文进行加密.解密处理 情景:在资源调度中,首先用户需要选择工作目标,然后跟据选择的工作目标不同而选择不同的账号和代理ip.处理过程如下:点击选择账号,在js中获取工作目标 ...

  7. FileTable初体验

    FileTable初体验 阅读导航 启用FILESTREAM设置 更改FILESTRAM设置 启用数据库非事务性访问级别 FileTable 在我接触FileTable之前,存储文件都是存储文件的链接 ...

  8. MySQL模式 : Strict Mode

    I. Strict Mode阐述 根据 mysql5.0以上版本 strict mode (STRICT_TRANS_TABLES) 的限制: 1).不支持对not null字段插入null值 2). ...

  9. 搭建Ubuntu12.04交叉编译服务器

    最近在公司学着搭建一台Linux服务器作为交叉编译的主机之用,服务器端选择了Ubuntu12.04 LTS桌面版,客户端采用Windows XP平台,使用SSH工具软件putty登录到Linux主机, ...

  10. 国外大师给PHP初学者的8条建议

    学习一门新语言可能会是一件很艰巨的任务,最好的办法就是借鉴前辈的经验已达到事半功倍,下面就是为php新手们准备的一些经验餐. 1.从OOP开始Naramore是SourceForge员工以及PHPWo ...