Problem Description
  Today is the 1st anniversary of BestCoder. Soda, the contest manager, gets a string s of length n. He wants to find three nonoverlapping substrings s[l1..r1], s[l2..r2], s[l3..r3] that:

1. 1≤l1≤r1<l2≤r2<l3≤r3≤n

2. The concatenation of s[l1..r1], s[l2..r2], s[l3..r3] is "anniversary".

 
Input
There are multiple test cases. The first line of input contains an integer T (1≤T≤100), indicating the number of test cases. For each test case:
There's a line containing a string s (1≤|s|≤100) consisting of lowercase English letters.
 
Output
For each test case, output "YES" (without the quotes) if Soda can find such thress substrings, otherwise output "NO" (without the quotes).
 

Sample Input

2
annivddfdersewwefary
nniversarya
 
Sample Output
YES
NO
 

我觉得我写的好无脑

#include<iostream>
#include<string>
using namespace std;
string s("anniversary");
int main()
{
int t;
cin>>t;
while(t--)
{
string ss;
cin>>ss;
int a,b,c,f=1;
for(int i=0;i<9;i++)
{
if(f)
for(int j=i+1;j<10;j++)
{
string s1(s,0,i+1);
string s2(s,i+1,(j-i));
string s3(s,j+1,(10-j));
a=ss.find(s1);
b=ss.find(s2,a+s1.size());
c=ss.find(s3,b+s2.size());
if(a!=-1&&b!=-1&&c!=-1)
{
cout<<"YES"<<endl;
f=0;break;
}
}
else break;
}
if(f)
cout<<"NO"<<endl;
}
return 0;
}

  

HDU5311 Hidden String的更多相关文章

  1. Hidden String(深搜)

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

  2. BestCoder 1st Anniversary B.Hidden String DFS

    B. Hidden String Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://bestcoder.hdu.edu.cn/contests/co ...

  3. hdu 5311 Hidden String

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

  4. 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)  ...

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

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

  6. BestCoder 1st Anniversary ($) 1002.Hidden String

    Hidden String Accepts: 437 Submissions: 2174 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 26 ...

  7. HDU 5311:Hidden String

    Hidden String  Accepts: 437  Submissions: 2174  Time Limit: 2000/1000 MS (Java/Others)  Memory Limit ...

  8. HDU 5311 Hidden String (暴力)

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

  9. hdu 5311 Hidden String(find,substr)

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

随机推荐

  1. Y86处理器的各个阶段

    0x00e:30f480000000        |              irmovl $128,%esp  实现所有Y86指令所需要的计算分为6个基本阶段:取值.译码.执行.访存.写回和更新 ...

  2. linux驱动面试题目汇总

    http://blog.csdn.net/blueice8601/article/details/7666427 1.linux驱动分类 2.信号量与自旋锁 3.platform总线设备及总线设备如何 ...

  3. poj 1050 To the Max (简单dp)

    题目链接:http://poj.org/problem?id=1050 #include<cstdio> #include<cstring> #include<iostr ...

  4. XSS 简单理解之:AntiSamy

    AntiSamy介绍 OWASP是一个开源的.非盈利的全球性安全组织,致力于应用软件的安全研究.我们的使命是使应用软件更加安全,使企业和组织能够对应用安全风险作出更清晰的决策.目前OWASP全球拥有1 ...

  5. android的生命周期

    1.运行状态:当一个活动处于栈的顶部时,这时活动就处于活动状态,系统是不愿意回收处于活动状态的,会影响用户体验. 2.暂停状态:当一个活动不再处于栈的顶部时,但仍然可见时,这时就是暂停状态了.处于暂停 ...

  6. mysql创建数据库(指定编码)

    如下脚本创建数据库yourdbname,并制定默认的字符集是utf8. CREATE DATABASE IF NOT EXISTS yourdbname DEFAULT CHARSET utf8 CO ...

  7. UVaLive6039 Uva1668 Let's Go Green

    一开始考虑所有边都是单独的一条路径 然后尽量多的合并 #include<cstdio> #include<cstring> #include<cstdlib> #i ...

  8. [NOIP2015pj题解]From某因为时间快了那么一点点超过下一位的蒟蒻(其实是纯代码).

    第一题,很水,直接上代码 #include <iostream> #include <fstream> #include <cstdlib> /* run this ...

  9. c#基础语言编程-集合

    引言 在c#常用的集合分为非泛型集合和泛型集合. 非泛型集合的类和接口位于System.Collections命名空间.这些接口和类定义各种对象(如列表.队列.位数组.哈希表和字典)的集合. 泛型集合 ...

  10. 关于MS office 180天后再次激活遇到的问题解决方法

    遇到的问题: 再次点击miniKMS  激活软件激活失败 : 我也不知道这是为什么?后来我在同一目录重装了一次,点击的还是我以前的那个KSM激活软件,出现的错误还是一样的.于是我想可能是这个激活软件的 ...