Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits\stdc++.h>
- using namespace std;
- int main()
- {
- int t;
- scanf("%d", &t);
- while(t--)
- {
- string s;
- cin >> s;
- int c1 = 0, c2 = 0, c3 = 0;
- for(int i = 0; i < s.length(); i++)
- {
- if(s[i] == 'A') c1++;
- else if(s[i] == 'B') c2++;
- else if(s[i] == 'C') c3++;
- }
- if((c2 == 2*c1 && c2 == 2*c3) || (c3 == c2 - c1 && c1 == c2 - c3))
- {
- printf("YES\n");
- }
- else printf("NO\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement