简直吐血。。第二种情况我手贱把ab和c进行了比较。。调死调不出来后来删了这个条件才A
AC代码:
#include<cstdio>
#include<ctype.h>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
#include<cstdlib>
#include<stack>
#include<cmath>
#include<queue>
#include<set>
#include<ctime>
#include<string.h>
#include<string>
using namespace std;
#define ll long long
#define eps 1e-8
#define MOD 1000000007
template<class T>
inline void scan_d(T &ret)
{
char c;
ret=0;
while((c=getchar())<'0'||c>'9');
while(c>='0'&&c<='9') ret=ret*10+(c-'0'),c=getchar();
}
char ch[100],a[100],b[100],c[100];
int main()
{
#ifdef GLQ
freopen("input.txt","r",stdin);
// freopen("o2.txt","w",stdout);
#endif // GLQ
int tc,i,j,k;
scanf("%d\n",&tc);
while(tc--)
{
i = 0;
char t;
while((t = getchar()) && t!='\n')
if((t>='a' && t <= 'z') || (t >='A' && t <='Z')) ch[i++] = t;
ch[i] = '\0';
int len = strlen(ch);
if(len < 5)
{
printf("No\n");
continue;
}
int ans = 0;
for(i = 1; (i+1)*2 < len; i++)
{
int flag1 = 1,flag2 = 1;
for(j = i+1; j <= i+1+i; j++)
{
if(ch[j] != ch[j-i-1])
{
flag1 = 0;
break;
}
}
if(flag1)
{
if(len-2*i-3 >= i) continue;
// if(i+i+2 >= len) continue;
for(k = i+i+2; k < len; k++)
if(ch[k] != ch[k-(i+i+2)])
{
flag2 = 0;
break;
}
if(flag2 == 1)
{
memset(a,'\0',sizeof(a));
memset(b,'\0',sizeof(b));
int nct = 0;
for(int I = i+i+2; I < len; I++) a[nct++] = ch[I];
a[nct] = '\0';
nct = 0;
for(int I = len-2*i-2; I <= i; I++) b[nct++] = ch[I];
b[nct] = '\0';
// cout<<a<<" "<<b<<endl;
if(strlen(a)>0 && strlen(b)>0 && strcmp(a,b)!=0)
{
ans = 1;
break;
}
}
}
}
if(ans)
{
printf("Yes\n");
continue;
}
for(i = 1; (i+1)*3 < len; i++)
{
int flag1 = 1,flag2 = 1;
for(j = i+1; j <= i+1+i; j++)
{
if(ch[j] != ch[j-i-1])
{
flag1 = 0;
break;
}
}
if(flag1)
{
// if(len-i-1 <= i+1) continue;
for(j = len-i-1; j < len ;j++)
if(ch[j] != ch[j-(len-i-1)])
{
flag2 = 0;
break;
}
if(flag2)
{
memset(a,'\0',sizeof(a));
memset(b,'\0',sizeof(b));
memset(c,'\0',sizeof(c));
int nct = 0;
for(k = 0; k <= i; k++) a[nct++] = ch[k];
a[nct] = '\0';
nct = 0;
for(k = i+i+2; k < len-i-1; k++) c[nct++] = ch[k];
c[nct] = '\0';
// cout<<a<<" "<<c<<endl;
if(strlen(c)>0 && strlen(a)>1)
{
for(j = 0; j < i; j++)
{
k = 0;
while(k <= j)
{
a[k] = ch[k];
k++;
}
a[k] = '\0';
k = j+1,nct = 0;
while(k <= i)
{
b[nct++] = ch[k];
k++;
}
b[nct] = '\0';
// cout<<a<<" "<<b<<" "<<c<<endl;
if(strlen(a)>0&&strlen(b)>0&&strcmp(a,b)!=0&&strcmp(a,c)!=0&&strcmp(b,c)!=0)
{
ans = 1;
break;
}
}
if(ans) break;
}
}
}
}
if(ans)
{
printf("Yes\n");
}
else printf("No\n");
}
return 0;
}