把anniversary分成三个区间,分别枚举每个区间在给定模板中的长度。每次枚举完一个区间,记录下区间长度和起始坐标,下次从剩下长度开始枚举,避免重复。

 #include<iostream>
#include<stdio.h>
#include<string.h>
#include<cmath>
#include<algorithm>
using namespace std;
const int MAXD = ;
const int MAXM = ;
const int INF = 0x3f3f3f3f;
typedef long long ll; int main()
{
//freopen("in.txt","r",stdin);
int T;
scanf("%d",&T);
char str[];
char *str2;
while(T--)
{
int flag=;
char a1[];
char a2[];
char a3[];
int len1;
int len2;
int len3;
char *b1,*b2,*b3;
scanf("%s",str);
str2="anniversary";
int len=strlen(str2);
for(int i=; i<len-; i++)
{
if(flag)
break;
for(int j=i+; j<len-; j++)
{
memset(a1,,sizeof(a1));
memset(a2,,sizeof(a2));
memset(a3,,sizeof(a3));
strncpy(a1,str2+,i+);
b1=strstr(str,a1);
if(b1==NULL)
continue;
len1=b1-str;
strncpy(a2,str2+i+,j-i);
b2=strstr(str+len1+i+,a2);
if(b2==NULL)
continue;
len2=b2-str;
strncpy(a3,str2+j+,len-j+);
b3=strstr(str+len2+j-i,a3);
if(b3==NULL)
continue;
flag=;
break;
}
}
if(flag)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
return ;
}

HDU 5311的更多相关文章

  1. hdu 5311 Hidden String

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5311 Hidden String Description Today is the 1st anniv ...

  2. hdu 5311 Hidden String (BestCoder 1st Anniversary ($))(深搜)

    http://acm.hdu.edu.cn/showproblem.php?pid=5311 Hidden String Time Limit: 2000/1000 MS (Java/Others)  ...

  3. (字符串) Hidden String -- HDU -- 5311

    链接: http://acm.hdu.edu.cn/showproblem.php?pid=5311 Time Limit: 2000/1000 MS (Java/Others)    Memory ...

  4. HDU 5311 Hidden String (优美的暴力)

    Hidden String Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) ...

  5. HDU 5311 Hidden String (暴力)

    题意:今天是BestCoder一周年纪念日. 比赛管理员Soda有一个长度为n的字符串s. 他想要知道能否找到s的三个互不相交的子串s[l1..r1], s[l2..r2], s[l3..r3]满足下 ...

  6. hdu 5311 Hidden String(find,substr)

    Problem Description Today is the 1st anniversary of BestCoder. Soda, the contest manager, gets a str ...

  7. hdu 5311(暴力)

    题意:要求在一个字符串中找出三段,然后能拼成一个固定的单词,问是否可行 BC周年庆第二题,我枚举了那个单词的切断位置,然后到给的字符串里分别找,然后就没有然后了``` #include<stdi ...

  8. hdu 5311 Hidden String 字符串

    BC一周年的题.这道题做比赛的时候A了小数据,终于评判的时候还是挂了,看来还是不认真思考的问题啊.交的时候 都没有信心过肯定是不行的.认真思考.敲一发,有信心过才是真正的acmer.赛后认真想了想,发 ...

  9. HDU 5311 Sequence

    Hidden String Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) ...

随机推荐

  1. C++:析构函数

    析构函数的特点: 1.析构函数与类名相同,但它前面必须加上波浪号~ 2.析构函数不返回任何值,在定义析构函数时,是不能说明它的类型的,甚至说明void类型也不能 3.析构函数没有参数,因此不能被重载. ...

  2. linux 进入包含空格文件名的文件夹

    可以使用加英文的引号cd  /usr/chen/java/"MyeClips\ 如果"\"在行末,是说明本行还未结束,下面一行和本行是一起的意思. 一般短格式的选项(一个 ...

  3. Android 类似时间轴的实现

    想要实现图片中的的时间轴的效果,设定了三种颜色,但是出来的只有一个黑色,还不是设定好的,而且长度很长的话不能滚动,下面上代码: 布局文件: <LinearLayout xmlns:android ...

  4. Topcoder 练习小记,Java 与 Python 分别实现。

    Topcoder上的一道题目,题目描述如下: Problem Statement      Byteland is a city with many skyscrapers, so it's a pe ...

  5. ehcache版本冲突

    以ehchache-core2.5为分水岭 缓存版本问题 版本不一样 配置不一样  ehcache-core-2.4.3.jar 与 ehcache-core-2.6.6 一 Caused by: n ...

  6. npm安装插件提示

    现在使用node的人群越来越多,咱也不能落后,得跟紧脚步才行. 今天使用 npm 安装插件的时候,出现以下提示,而且,安装程序看着好像终止了.而且,看到一个exit单词,就认为说安装出错了. $ np ...

  7. JAVA调用易信接口向指定好友推送消息(一)背景需求

    众所周知,中国电信内部一直使用易信群进行交流 各种工作交流都在易信群里面沟通 包括投诉处理,障碍报修,拍照上传 最重要的就是每天甚至每个时点的指标完成情况的通报 所以只能用4个字来形容 String ...

  8. linq 之左连接

    List<ArticleModel> articleList = articleRepository.GetAllArticle(); List<UsersModel> use ...

  9. wince和window mobile winphone

    windows mobile是微软在2000年左右推出的针对移动平台的操作系统,这个系统一直使用到三年前,微软开始启用metro界面,将windows mobile改名为windows phone. ...

  10. UVA 1151 Buy or Build (MST最小生成树,kruscal,变形)

    题意: 要使n个点之间能够互通,要使两点直接互通需要耗费它们之间的欧几里得距离的平方大小的花费,这说明每两个点都可以使其互通.接着有q个套餐可以选,一旦选了这些套餐,他们所包含的点自动就连起来了,所需 ...