fork download
  1. //Sarvagya Agarwal
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. #define rep(i,a,b) for(int i=a;i<=b;++i)
  5. #define is(X) cout<<#X<<" is "<<X<<endl
  6. #define ff first
  7. #define ll long long
  8. #define ss second
  9. #define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
  10. #define pb push_back
  11. #define mp make_pair
  12. #define openin freopen("input.txt","r",stdin)
  13. #define openout freopen("output.txt","w",stdout)
  14. int main()
  15. {
  16. fast;
  17. //openin;
  18. int t;
  19. cin>>t;
  20. while(t--)
  21. {
  22. string s,temp1,temp2,temp3,temp4;
  23. cin>>s;
  24. set<string> ss;
  25. int n = s.size();bool flag=false;
  26. for(int i=1;i<n;++i)
  27. {
  28. for(int j=i+1;j<n;++j)
  29. {
  30. for(int k=j+1;k<n;++k)
  31. {
  32. temp1="";temp2="";temp3="";temp4="";
  33. for(int z = 0;z<i;z++)temp1+=s[z];
  34. for(int z = i;z<j;z++)temp2+=s[z];
  35. for(int z = j;z<k;z++)temp3+=s[z];
  36. for(int z = k;z<n;z++)temp4+=s[z];
  37. if(temp1.size()==0 || temp2.size()==0 || temp3.size()==0 || temp4.size()==0)continue;
  38. ss.insert(temp1);ss.insert(temp2);ss.insert(temp3);ss.insert(temp4);
  39. if(ss.size()==4)
  40. {
  41. flag=true;
  42. cout<<"YES\n";
  43. break;
  44. }
  45. ss.clear();
  46. }
  47. if(flag)break;
  48. }
  49. if(flag)break;
  50. }
  51. if(!flag)cout<<"NO\n";
  52. }
  53.  
  54. return 0;
  55. }
  56.  
Success #stdin #stdout 0s 3412KB
stdin
2
ababca
aaabb
stdout
YES
NO