Hidden String

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

Total Submission(s): 803    Accepted Submission(s): 302

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
 
Source
 
Recommend





#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h> using namespace std; char str[10001];
struct node
{
int x;
char s;
} q[10010]; int main()
{
int T;
char a[] = "anniversary";
scanf("%d",&T);
while(T--)
{
int flag = 0;
scanf("%s",str);
int l = strlen(str);
int ll = strlen(a);
int num = 0;
for(int j=0; j<l; j++)
{
for(int i=1; i<=ll; i++)
{
if(strncmp(str+j,a+num,i) == 0)
{
int num1 = num + i;
for(int jj=j+i; jj<l; jj++)
{
for(int ii=1; ii<=ll-i; ii++)
{
if(strncmp(str+jj,a+num1,ii) == 0)
{
int num2 = num1 + ii;
for(int jjj=jj+ii; jjj<l; jjj++)
{
if(strncmp(str+jjj,a+num2,ll-num2) == 0)
{
printf("YES\n");
flag = 1;
break;
}
}
}
if(flag == 1)
{
break;
}
}
if(flag == 1)
{
break;
}
}
if(flag == 1)
{
break;
}
}
if(flag == 1)
{
break;
}
}
if(flag == 1)
{
break;
} }
if(flag == 0)
{
printf("NO\n");
}
}
return 0;
}

 

HDU 5311 Sequence的更多相关文章

  1. HDU 3397 Sequence operation(线段树)

    HDU 3397 Sequence operation 题目链接 题意:给定一个01序列,有5种操作 0 a b [a.b]区间置为0 1 a b [a,b]区间置为1 2 a b [a,b]区间0变 ...

  2. HDU 5919 Sequence II(主席树+逆序思想)

    Sequence II Time Limit: 9000/4500 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) To ...

  3. hdu 5311 Hidden String

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

  4. hdu 5146 Sequence

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5146 Sequence Description Today we have a number sequ ...

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

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

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

  7. HDU 6395 Sequence 【矩阵快速幂 && 暴力】

    任意门:http://acm.hdu.edu.cn/showproblem.php?pid=6395 Sequence Time Limit: 4000/2000 MS (Java/Others)   ...

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

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

  9. hdu 5312 Sequence(数学推导——三角形数)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5312 Sequence Time Limit: 2000/2000 MS (Java/Others)  ...

随机推荐

  1. PHP fSQL Tutorial

    PHP fSQL Tutorial This tutorial is designed to give a brief overview of the PHP fSQL API since versi ...

  2. Tcl之Read files for synthesis

    The following file is to read all design files into syntehsis tool automatically, like Cadence RTL C ...

  3. 2星|《约见投资人》:A股上市公司软文集

    约见资本人:58家上市公司创始人亲述创业之路 全书写了58个A股上市公司的故事,基本是宣传上市公司老总的软文.基本的套路是创始人历尽苦难创立了公司,取得了好业绩.最希望看的分析与数据几乎没有.看了一小 ...

  4. canvas一周一练 -- canvas绘制太极图(6)

    运行效果: <!DOCTYPE html> <html> <head> </head> <body> <canvas id=" ...

  5. Layui数据表单的编辑

    使用layui对单元格进行编辑并保存 先是要引入layui的JS和CSS 然后创建一个表格 而重要的是edit这个属性,只有使用了这个属性的一列数据表格才可以编辑,其余的都不可以进行编辑 然后使用la ...

  6. [转]SSD固态存储大观(一)

    From: http://blog.51cto.com/alanwu/1405874 Contents 1.概述... 1 2.FusionIO:Pcie SSD的始作俑者... 2 3.Intel ...

  7. Chrome升级后打开新的标签页变样了……

    最近更新Chrome后,打开新的标签页完全变样了,让人不知所措,特别是没有了那个“最近关闭标签页”按钮,这让我抓狂…… PS:Chrome版本号为:29.0.1547.76 m PPS:最新版已无法修 ...

  8. jsp中的basePath,获取应用的路径

    1 2 3 4 5 String path = request.getContextPath();      String basePath = request.getScheme()+": ...

  9. 如何同步iframe与嵌入内容的高度

    最近频繁的做一些通过iframe在a页面嵌入b页面需求.总结下来,有以下问题需要解决 1.如何同步iframe与嵌入内容的高度 2.将b页面载入到a页面后,如何隐藏掉b页面上的元素,如左导航,顶部导航 ...

  10. 17Aspectij

    17Aspectij-2018/07/31 1.Aspectj基于xml 前置通知 method : 通知,及方法名 pointcut :切入点表达式,此表达式只能当前通知使用. pointcut-r ...