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. 【转】Android 驱动开发系列四

    原文网址:http://www.2cto.com/kf/201304/202040.html 时隔多日,终于都抽出时间来写blog了.废话不多说,接着上一篇,这里将介绍如何编写HAL层(硬件抽象层)对 ...

  2. 关于在C#中数组(byte[])复制方式

    {            int[] src = new[] { 1, 2, 3, 4, 5, 6 };            const int destLen = 4;//目标数组大小       ...

  3. 265行JavaScript代码的第一人称3D H5游戏Demo【个人总结1】

    本文目的是分解前面的代码.其实,它得逻辑很清楚,只是对于我这种只是用过 Canvas 画线(用过 Fabric.js Canvas库)的人来说,这个还是很复杂的.我研究这个背景天空也是搞了一天,下面就 ...

  4. HDOJ/HDU 2547 无剑无我(两点间的距离)

    Problem Description 北宋末年,奸臣当道,宦官掌权,外侮日亟,辽军再犯.时下战火连连,烽烟四起,哀鸿遍野,民不聊生,又有众多能人异士群起而反,天下志士云集响应,景粮影从. 值此危急存 ...

  5. cygwin with openssh

    新建系统变量 CYGWIN=ntsec path添加 ;c:\cygwin\bin 之后参考http://blog.csdn.net/benkaoya/article/details/8884677 ...

  6. MongoDB性能优化指南

    一.索引 MongoDB 提供了多样性的索引支持,索引信息被保存在system.indexes 中,且默认总是为_id创建索引,它的索引使用基本和MySQL 等关系型数据库一样.其实可以这样说说,索引 ...

  7. poj 2312 Battle City【bfs+优先队列】

      Battle City Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7579   Accepted: 2544 Des ...

  8. FIREDAC TFDCONNECTION连接MYSQL数据库

    FIREDAC TFDCONNECTION连接MYSQL数据库 procedure TfrmDB.ConnectDB;begin FDMoniFlatFileClientLink1.FileName ...

  9. DataGridView 选中行 分类: DataGridView 2015-01-22 09:07 51人阅读 评论(0) 收藏

    说明: (1)命名 DataGridView 名称:dgvStockFirst 行索引:recordIndex (2)设置DataGridView属性: SelectionMode=FullRowSe ...

  10. 【Android - 框架】之OkHttp的使用

    OkHttp是一个非常优秀的网络访问框架,当下非常火的Retrofit的底层就是使用OkHttp进行封装的.接下来介绍以下OkHttp的简单使用. 1.导入依赖 在Android Studio中,在M ...