题意:要求在一个字符串中找出三段,然后能拼成一个固定的单词,问是否可行

BC周年庆第二题,我枚举了那个单词的切断位置,然后到给的字符串里分别找,然后就没有然后了```

 #include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std; char s[];
char t[]=" anniversary";
int l=; bool check(int a,int b){
int pos=,p=;
int i,j;
bool f1=,f2=,f3=;
for(i=;i<=l;i++){
if(!f1){
if(s[i]==t[]){
int pos=;
bool f=;
for(pos=;pos<=a&&f;pos++){
if(s[i+pos-]!=t[pos])f=;
}
if(f){
f1=;
i=i+pos-;
}
}
}
else if(!f2){
if(s[i]==t[a+]){
int pos=a+;
bool f=;
for(pos=a+;pos<=b&&f;pos++){
if(s[i+pos-a-]!=t[pos])f=;
}
if(f){
f2=;
i=i+pos-a-;
}
}
}
else if(!f3){
if(s[i]==t[b+]){
int pos=b+;
bool f=;
for(pos=b+;pos<=&&f;pos++){
if(s[i+pos-b-]!=t[pos])f=;
}
if(f)return ;
}
}
}
return ;
} int main(){
int T;
scanf("%d",&T);
while(T--){
scanf("%s",s+);
l=strlen(s+);
int i,j;
bool f=;
for(i=;i<&&f;i++){
for(j=i+;j<=&&f;j++){
if(check(i,j)==){
f=;
}
}
}
if(!f)printf("YES\n");
else printf("NO\n");
}
return ;
}

hdu 5311(暴力)的更多相关文章

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

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

  2. HDU 5311 Hidden String (暴力)

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

  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. (字符串) Hidden String -- HDU -- 5311

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

  6. HDU 6351暴力枚举 6354计算几何

    Beautiful Now Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)T ...

  7. HDU 5944 暴力

    Fxx and string Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others)T ...

  8. hdu 4039 暴力

    思路:用map将每个字符串与一个数字进行对应,然后暴力统计就好了 #include<cstring> #include<iostream> #include<cstdio ...

  9. hdu 4952 暴力

    http://acm.hdu.edu.cn/showproblem.php?pid=4952 给定x,k,i从1到k,每次a[i]要是i的倍数,并且a[i]大于等于a[i-1],x为a0 递推到下一个 ...

随机推荐

  1. Unity中的文件

    Unity中的文件大致分为一下几类: 1.资源文件: 导入后,除非是修改,否则不会变化的文件.例如:fbx文件.贴图文件.音频文件.视频文件.动画文件等. 这些文件在导入到Unity的时候,都会进行转 ...

  2. SqlServer和Oracle判断表和列是否存在

    SqlServer .判断表Users是否存在 if object_id(N'Users',N'U') is not null print '存在' else print '不存在' .判断表User ...

  3. hdu2609 最小表示法

    Give you n ( n < 10000) necklaces ,the length of necklace will not large than 100,tell me How man ...

  4. python-day28--logging模块

    1.默认情况下Python的logging模块将日志打印到了标准输出中,且只显示了大于等于WARNING级别的日志,这说明默认的日志级别设置为WARNING(日志级别等级CRITICAL > E ...

  5. 如何用xmlspy将xml文档生成xsd文件

    所以我们有必要知道如何通过xmlspy这个非常方便的工具进行xml的转换工作.点击“File”-“New”系统会弹出“create new document”的窗口,此时选择“xml XML docu ...

  6. cas HttpServletRequestWrapperFilter

    HttpServletRequestWrapperFilter 作用其实很简单就是 在HttpServletRequest对象在包装一次,让其支持getUserPrincipal,getRemoteU ...

  7. POJ 3685 Matrix 二分 函数单调性 难度:2

      Memory Limit: 65536K Total Submissions: 4637   Accepted: 1180 Description Given a N × N matrix A, ...

  8. POJ 2586 Y2K Accounting Bug 贪心 难度:2

    Y2K Accounting Bug Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10537   Accepted: 52 ...

  9. C语言strrev()函数:字符串逆置(倒序、逆序)

    头文件:#include<string.h> strrev()函数将字符串逆置,其原型为:    char *strrev(char *str); [参数说明]str为要逆置的字符串. s ...

  10. 关于RM中的X3014错误,以及mul() 、天空盒

    关于  error X3014: incorrect number of arguments to numeric-type constructor 这个错误应该是某个类似float4 这样的变量初始 ...