Advertisement
Guest User

Untitled

a guest
Oct 1st, 2014
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <string.h>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int T,s;
  8. int A,B,C;
  9. char str[1000];
  10. bool bb;
  11.  
  12. cin >> T;
  13. while (T--)
  14. {
  15. A=0,B=0,C=0;bb=1;
  16. cin >> str;
  17. s = strlen(str);
  18. for (int i=0; i<s; ++i)
  19. {
  20. if (str[i] != 'a' && str[i] != 'b' && str[i] != 'c' && str[i] != 'A' && str[i] != 'B' && str[i] != 'C')
  21. {
  22. bb=0;
  23. break;
  24. }
  25.  
  26. if (str[i] == 'a')
  27. --A;
  28. if (str[i] == 'b')
  29. --B;
  30. if (str[i] == 'c')
  31. --C;
  32. if (str[i] == 'A')
  33. ++A;
  34. if (str[i] == 'B')
  35. ++B;
  36. if (str[i] == 'C')
  37. ++C;
  38. }
  39. if (A == 0 && B == 0 && C == 0 && bb==1)
  40. cout << "YES" << endl;
  41. else
  42. cout << "NO" << endl;
  43. }
  44.  
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement