暴力模拟
细节处理很重要。。。
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std; char s1[],s[];
int len1,len;
int t;
char a[],b[],c[]; int solved1 (int l,int len){
int temp=,j;
for (int i=;i*<=len;i++){
if ((len-i*)%||len<=i*)
continue ;
j=(len-i*)/;
if (i==j){
int flag=;
for (int z=;z<i;z++)
if (s[l+z]!=s[l+z+i]){
flag=;
break ;
}
if (flag)
continue ;
}
temp=;
for (int z=;z<i+j+i;z++)
if (s[l+z]!=s[l+z+i+j]){
temp=;
break ;
}
if (temp)
return temp;
}
return temp;
}
int solved2 (int l,int len){
int temp=;
int j,k;
for (int i=;i*<=len;i++){
for (int j=;(j+i)*<=len;j++){
if (len<=(i+j)*)
continue ;
if (i==j){
int flag=;
for (int z=;z<i;z++)
if (s[l+z]!=s[l+z+i]){
flag=;
break ;
}
if (flag)
continue ;
}
k=len-*(i+j);
if (k==i){
int flag=;
for (int z=;z<i;z++)
if (s[l+z]!=s[l+z+i+i+j+j]){
flag=;
break ;
}
if (flag)
continue ;
}
if (k==j){
int flag=;
for (int z=i;z<i+j;z++)
if (s[l+z]!=s[l+z+j+i+j]){
flag=;//cout<<z<<" "<<z+k<<endl;
break ;
}
if (flag)
continue ;
}
temp=;
for (int z=;z<i+j;z++)
if (s[l+z]!=s[l+z+i+j]||s[l+z]!=s[l+z+i+j+i+j+k]){
temp=;
break ;
}
if (temp)
return temp;
}
}
return temp;
} int solved (){
return solved1(,len)+solved2(,len);
} int main (){
cin>>t;
while (t--){
//cin.ignore ();
cin>>s1;
len1=strlen (s1);
len=;
memset (s,'\0',sizeof s);
for (int i=;i<len1;i++)
if ((s1[i]>='a'&&s1[i]<='z')||(s1[i]>='A'&&s1[i]<='Z')){
s[len++]=s1[i];
}//cout<<len<<" "<<s<<endl;
//if (solved1()) cout<<"1"<<endl;
if (solved())
printf ("Yes\n");
else printf ("No\n");
}
return ;
}