fork download
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int t,i;
  5. scanf("%d",&t);
  6. for(i=0;i<t;i++)
  7. {
  8. char s[1001],a[501],b[501],A;
  9. int c=0,j,e,d,x,k,y=0;
  10. scanf("%s",&s);
  11. for(j=0;s[j]!='\0';j++)
  12. c++;
  13. d=c/2;
  14. if(c%2==0)
  15. {
  16. for(j=0;j<d;j++)
  17. a[j]=s[j];
  18. e=0;
  19. for(j=d;j<c;j++)
  20. {
  21. b[e]=s[j];
  22. e++;
  23. }
  24. }
  25. if(c%2!=0)
  26. {
  27. for(j=0;j<d;j++)
  28. a[j]=s[j];
  29. e=0;
  30. for(j=d+1;j<c;j++)
  31. {
  32. b[e]=s[j];
  33. e++;
  34. }
  35. }
  36. for(j=0;j<d;j++)
  37. {
  38. x=0;
  39. for(k=0;b[k]!='\0';k++)
  40. {
  41. if(a[j]==b[k])
  42. {
  43. x++;
  44. break;
  45. }
  46. }
  47. if(x>0)
  48. {
  49. b[k]=A;
  50. }
  51. else if(x==0)
  52. y++;
  53. }
  54. if(y>0)
  55. printf("NO\n");
  56. else if(y==0)
  57. printf("YES\n");
  58. }
  59. return 0;
  60. }
  61.  
Success #stdin #stdout 0s 2252KB
stdin
1
cccccdrdccccc
stdout
NO