注意看题,只能切去一段
All that we can manage to do is to cut out some substring from the banner, i.e. several consecutive letters.
这里的 some 是某一的意思,因为后面的 substring 没有加 s .......
if the beginning or the end of the original banner was cut out, only one part remains.
i.e. after a substring is cut, several first and last letters are left, it is allowed only to glue the last letters to the right of the first letters.
因为只能切去连续的一段,所以只可能有三种情况
1.CODEFORCES------
2.-----CODEFORCES
3.CODEFORCES的前半部分-----CODEFORCES的后半部分
method 1: 15ms
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
using namespace std;
///char s[100+10];
string s,str1,str2;
int main()
{
char des[11]="CODEFORCES";
while(cin>>s)
{
int len=s.length();
int flag=0;
if(len<10) { printf("NO\n");continue; } ///长度不够肯定不行
for(int i=0;i<=10;i++) ///这里是10不是len
{
/// memcpy(str,s,i);
str1=s.substr(0,i);
/// memcpy(str+i,s+i+len-10,10-i);
str2=s.substr(i+len-10,10-i);
/// if(!strcmp(str,des))
if(str1+str2==des) {flag=1;break;} ///string还可以这样加 哈哈
}
if(flag) printf("YES\n");
else printf("NO\n");
}
return 0;
}
method 2: 30ms
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
char s[100+10];
int main()
{
char des[11]="CODEFORCES",str[11];
///printf("%s\n",des);
str[10]='\0';
while(~scanf("%s",s))
{
int len=strlen(s);
/// int cnt=0,k=0;
int flag=0;
if(len<10) { printf("NO\n");continue; }
for(int i=0;i<=10;i++)
{
memcpy(str,s,i);
memcpy(str+i,s+i+len-10,10-i); ///强大的memcpy
if(!strcmp(str,des)) {flag=1;break;}
}
if(flag) printf("YES\n");
else printf("NO\n");
}
return 0;
}