Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #include<cmath>
- using namespace std;
- int main() {
- // your code goes here
- int testCases;
- cin>>testCases;
- while(testCases-- >0){
- int bitSize;
- cin>>bitSize;
- string S;
- cin>>S;
- int numberOfZeroes=0;
- int numberOfOnes=0;
- for(int i=0;i<S.length();i++){
- if(S[i]=='0'){
- numberOfZeroes++;
- }else{
- numberOfOnes++;
- }
- }
- if(S.length()%2==0){
- if(numberOfOnes==numberOfZeroes){
- cout<<"YES"<<endl;
- }else if(numberOfZeroes%2==0 && numberOfOnes%2==0){
- cout<<"YES"<<endl;
- }else{
- cout<<"NO"<<endl;
- }
- }else{
- cout<<"YES"<<endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement