fork(1) download
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cstring>
  4. using namespace std;
  5. int main(void)
  6. {
  7. int t, i, j, y;
  8. scanf ("%d", &t);
  9. for (t; t > 0; --t)
  10. {
  11. char c[100000];
  12. scanf ("%s", c);
  13. y = strlen(c);
  14. if (y % 2 != 0)
  15. {
  16. printf ("NO\n");
  17. }
  18. else
  19. {
  20. int d = 0, ans = 0, test = 0, hah = 0;
  21. for (i = 0; i <= y / 2 - 1; ++i)
  22. {
  23. if (c[i] == 'T')
  24. test = test + 1;
  25. else
  26. d = d + 1;
  27. }
  28. for (j = y / 2; j < y; ++j)
  29. {
  30. if (c[j] == 'T')
  31. ans = ans + 1;
  32. else
  33. hah = hah + 1;
  34. }
  35. if ((test == hah) && (test > 0) && (test > d))
  36. printf ("YES\n");
  37. else
  38. printf ("NO\n");
  39. }
  40. }
  41. return 0;
  42. }
Success #stdin #stdout 0s 3320KB
stdin
1
TTDTDD
stdout
YES