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. poi获取word批注

    package test; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundExcept ...

  2. Angular——内置服务

    $location <!DOCTYPE html> <html lang="en" ng-app="App"> <head> ...

  3. 北大ACM(POJ1017-Packets)

    Question:http://poj.org/problem?id=1017 问题点:贪心. Memory: 224K Time: 32MS Language: C++ Result: Accept ...

  4. JAVA环境变量配置后未变动配置失效处理

    环境: Windows 7 x64 配置方案来源于教程: http://www.mamicode.com/info-detail-563355.html 配置方案出现的问题: 正确配置JAVA环境变量 ...

  5. JMeter在linux上分布式压测步骤(二)

    哈喽,我又来了~ 前提:三台linux虚拟机,一台作为master,另外两台作为slave. 一.server端 1.修改1099端口,client和server通信的端口,可以不修改,默认就是109 ...

  6. netstat查看服务器连接数端口并发数

    简介 Netstat 命令用于显示各种网络相关信息,如网络连接,路由表,接口状态 (Interface Statistics),masquerade 连接,多播成员 (Multicast Member ...

  7. CAD在网页中如何实现嵌套打印?

    当用户需要打印两个控件的图纸时,可以采用嵌套打印实现.点击此处在线演示. 实现嵌套打印功能,首先将两个控件放入网页中,js代码如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ...

  8. vue之基础---组件基础

    (1)基本示例 Vue组件示例 /* 先注册组件,定义一个名为button-component的新组件 */ Vue.component('button-component',{ data:funct ...

  9. gym101343 2017 JUST Programming Contest 2.0

    A.On The Way to Lucky Plaza  (数论)题意:m个店 每个店可以买一个小球的概率为p       求恰好在第m个店买到k个小球的概率 题解:求在前m-1个店买k-1个球再*p ...

  10. 在添加新内容时,creatat没有数据

    首先找到controller中的add方法,然后是执行了Service.insert()方法 然后找到service对应的impl方法, impl方法中的 public void insert(Cus ...