Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string.h>
- using namespace std;
- int main()
- {
- int T,s;
- int A,B,C;
- char str[1000];
- bool bb;
- cin >> T;
- while (T--)
- {
- A=0,B=0,C=0;bb=1;
- cin >> str;
- s = strlen(str);
- for (int i=0; i<s; ++i)
- {
- if (str[i] != 'a' && str[i] != 'b' && str[i] != 'c' && str[i] != 'A' && str[i] != 'B' && str[i] != 'C')
- {
- bb=0;
- break;
- }
- if (str[i] == 'a')
- --A;
- if (str[i] == 'b')
- --B;
- if (str[i] == 'c')
- --C;
- if (str[i] == 'A')
- ++A;
- if (str[i] == 'B')
- ++B;
- if (str[i] == 'C')
- ++C;
- }
- if (A == 0 && B == 0 && C == 0 && bb==1)
- cout << "YES" << endl;
- else
- cout << "NO" << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement