$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. [转]Libev教程

    libev Table of Contents 1 libev 1.1 About The Code 1.2 EventLoop 1.3 Watcher 1.4 How it works 1.4.1 ...

  2. Asp.Net中使用Couchbase——Memcached缓存使用篇

    Asp.Net中使用Couchbase——Memcached缓存使用篇 前言 在上一篇Asp.Net中使用Couchbase——Memcached缓存入门篇http://www.cnblogs.com ...

  3. formValidator

    formValidator输入验证.异步验证实例 + licenseImage验证码插件实例应用   实例技术:springmvc 实现功能:完整用户登录流程.输入信息规则校验.验证码异步校验. 功能 ...

  4. elasticsearch文档-modules

    elasticsearch文档-modules modules 模块 cluster 原文 基本概念 cluster: 集群,一个集群通常由很多节点(node)组成 node: 节点,比如集群中的每台 ...

  5. hdu4414(DFS 找十字架数量)

    Problem Description The Nazca Lines are a series of ancient geoglyphs located in the Nazca Desert in ...

  6. 二.redis 数据类型

    本文介绍下redis支持的各种数据类型包括string,list ,set ,sorted set 和hash 1. keysredis本质上一个key-value db,所以我们首先来看看他的key ...

  7. Android过滤Logcat输出

    logcat和grep配合使用 1.打印特定tag的log,如打印Tag为Adm的Log        adb logcat | grep Adm        adb logcat | grep - ...

  8. 简单使用JSON,JavaScript中创建 JSON 对象(一)

    JSON:JavaScript 对象表示法(JavaScript Object Notation). JSON 是存储和交换文本信息的语法.类似 XML. JSON 比 XML 更小.更快,更易解析. ...

  9. 腾讯地图api接收坐标提交坐标

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  10. linux php 安装GD库

    linux下为php添加GD库的步骤如下: 一.下载 gd-2.0.33.tar.gz http://www.boutell.com/gd/ jpegsrc.v6b.tar.gz http://www ...