把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. spring autoWire注解

    1.autowire注解,可以用来获得applicationContext,ResourceLoader,BeanFactory的注入 autoWire会获得相应资源 2.autoWire注解还可以用 ...

  2. iOS 精确定时器

    Do I need a high precision timer? Don't use a high precision timer unless you really need it. They c ...

  3. [cocoapods]如何卸载cocoapods

    今天我们来讲一下cocoapods的删除步骤! 1.移除pod组件,打开终端执行which pod 然后输出了路径,我的是 /usr/local/bin/pod 2. 移除Cocoapods组件,继续 ...

  4. Centos硬件信息查看命令

    [root@yan-001 ~] # uname -a # 查看内核/操作系统/CPU信息的linux系统信息命令 [root@yan-001 ~] # head -n 1 /etc/issue # ...

  5. Vim的可视模式

    可视模式可以看到选中的字符串, 并对其进行操作 v:进入字符选择模式 V:进入行选择模式 ctrl-v(Window是ctrl-q):进入block选择模式 o:移动光标到选择的另一端 O:移动光标到 ...

  6. Android 下log的使用总结

    Android 下log的使用总结 一:在源码开发模式下 1:包含头文件: #include <cutils/log.h> 2:定义宏LOG_TAG #define LOG_TAG &qu ...

  7. IOS刷新数据

    在一个项目开发过程中为了更好的体验经常会用到下拉刷新更新数据,当然也伴随一些上拉加载更多数据的情况:当前比较火的EGOTableViewPullRefresh只实现了下拉功能,而没有上拉的功能.这里介 ...

  8. LingPipe-TextClassification(文本分类)

    What is Text Classification? Text classification typically involves assigning a document to a catego ...

  9. 自动化:Appium运行成功,取得一个小的胜利

    看过乙醇大神的博文,然后又看了一些大神的博文,自己陆陆续续的折腾了一个月,今天上午的时候,appium终于跑起来了.纪念下,在自动化路上取得的一个小胜利 Appium版本:1.2 Python版本:2 ...

  10. struct TABLE

    struct TABLE { TABLE() {} /* Remove gcc warning */ TABLE_SHARE *s; handler *file; TABLE *next, *prev ...