CodeForces 667C Reberland Linguistics
$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的更多相关文章
- Codeforces 667C Reberland Linguistics 记忆化搜索
		
链接 Codeforces 667C Reberland Linguistics 题意 给你一个字符串,除去前5个字符串后,使剩下的串有长度为2或3的词根组成,相邻的词根不能重复.找到所有的词根 思路 ...
 - Codeforces 667C Reberland Linguistics【DFS】
		
一道卡题意的题. 题目链接: http://codeforces.com/problemset/problem/667/C 题意: 一个串可以看成一个长度大于4的根,加上其后面的若干个相邻(in a ...
 - CodeForces 666A Reberland Linguistics(DP)
		
A. Reberland Linguistics time limit per test 1 second memory limit per test 256 megabytes input stan ...
 - Codeforces.666A.Reberland Linguistics(DP)
		
题目链接 \(Description\) 给定串s,其由一个基本串后加任意多个长度为2或3的后缀串构成,要求基本串长度>4且相邻后缀串不相同.在基本串任意确定的情况下,求所有可能的后缀串. \( ...
 - codeforces 667C C. Reberland Linguistics(dp)
		
题目链接: C. Reberland Linguistics time limit per test 1 second memory limit per test 256 megabytes inpu ...
 - Codeforces Round #349 (Div. 1) A. Reberland Linguistics 动态规划
		
A. Reberland Linguistics 题目连接: http://www.codeforces.com/contest/666/problem/A Description First-rat ...
 - Codeforces Round #349 (Div. 1) A. Reberland Linguistics dp
		
题目链接: 题目 A. Reberland Linguistics time limit per test:1 second memory limit per test:256 megabytes 问 ...
 - 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 ...
 - Codeforces Round #349 (Div. 2)  C. Reberland Linguistics   DP+set
		
C. Reberland Linguistics First-rate specialists graduate from Berland State Institute of Peace a ...
 
随机推荐
- codeforces #275 div2题解
			
A题大意: 给你l,r,问你在l~r之间,是否存在 a和b互质 , b和c互质 ,但是 a,c不互质 的情况:其中l<=a<b<c<=r;如果存在,就输出a,b,c;不存在就输 ...
 - 什么是Angular JS?
			
Angular JS学习笔记——什么是Angular JS? Angular JS是一个由Google维护的开源的Javascript框架,主要作者为: Misko Hevery(angular JS ...
 - python 获取当前时间
			
我有的时候写程序要用到当前时间,我就想用python去取当前的时间,虽然不是很难,但是老是忘记,用一次丢一次,为了能够更好的记住,我今天特意写下python 当前时间这篇文章,如果你觉的对你有用的话, ...
 - GitHub上搭建个人网站
			
大致如下步骤: 1.注册Git账号 2.创建SSH keys 3.新建repository --- 4.设置网站 5.clone库到本地 6.提交.上传 7.预览 本教程默认你了解GitHub的基础之 ...
 - Java学习笔记——MySQL的安装使用以及SQL语法简介
			
在 Java 的开发中,数据库的应用是非常必要的,下面,我们为Java对于数据库的应用做一些必要的准备工作.. Java 对数据库的应用统称为 JDBC. JDBC(Java Data Base Co ...
 - jQuery判断浏览器类型
			
if ($.browser.msie) { alert("IE浏览器"); } else if ($.browser.opera) { alert("opera浏览器&q ...
 - ibatis-Spring 整合
			
这两天一直在研究ibatis与spring的整合 一个小小的demo搞的我头晕目眩的,但程序一旦跑起来了,突然有一种豁然开朗,重见天日,感觉生活很美好的感觉!,也许,这就是那一行行的代码带给我们的不同 ...
 - QQ登录(OAuth2.0)
			
QQ登录(OAuth2.0) 那些年,我们开发的接口之:QQ登录(OAuth2.0) 吴剑 2013-06-14 原创文章,转载必须注明出处:http://www.cnblogs.com/wujian ...
 - 启动mysql错误解决方案,学会查看错误日志:mysql.sock丢失,mysqld_safe启动报错
			
本人还是个菜鸟,下面是我的经验之谈,能解决一些问题,有不对的地方,敬请斧正. 我的是CentOS6.3+MySQL5.1.57. 重启了一次服务器后,使用> mysql -u root -p登陆 ...
 - 强悍的跨平台开源多媒体中心XBMC介绍
			
强悍的跨平台开源多媒体中心XBMC介绍 最近都在了解Android下的音视频,因为最近需要做一个多媒体中心的APP,其中了解了一个开源项目XMBC,一个十分强大的开源多媒体中心,而且可以应用在多个平台 ...