Advertisement
Promi_38

cf 1579A

Sep 28th, 2021
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include<bits\stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.    int t;
  8.    scanf("%d", &t);
  9.    
  10.    while(t--)
  11.    {
  12.         string s;
  13.         cin >> s;
  14.        
  15.         int c1 = 0, c2 = 0, c3 = 0;
  16.         for(int i = 0; i < s.length(); i++)
  17.         {
  18.             if(s[i] == 'A') c1++;
  19.             else if(s[i] == 'B') c2++;
  20.             else if(s[i] == 'C') c3++;
  21.         }
  22.         if((c2 == 2*c1 && c2 == 2*c3) || (c3 == c2 - c1 && c1 == c2 - c3))
  23.         {
  24.             printf("YES\n");
  25.         }
  26.         else printf("NO\n");
  27.    }
  28. }
  29.  
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement