Advertisement
Warmachine28

Untitled

Feb 11th, 2022
753
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.80 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #include<cmath>
  3. using namespace std;
  4.  
  5. int main() {
  6.     // your code goes here
  7.     int testCases;
  8.     cin>>testCases;
  9.    
  10.     while(testCases-- >0){
  11.         int bitSize;
  12.         cin>>bitSize;
  13.        
  14.         string S;
  15.         cin>>S;
  16.        
  17.         int numberOfZeroes=0;
  18.         int numberOfOnes=0;
  19.         for(int i=0;i<S.length();i++){
  20.             if(S[i]=='0'){
  21.                 numberOfZeroes++;
  22.             }else{
  23.                 numberOfOnes++;
  24.             }
  25.         }
  26.        
  27.         if(S.length()%2==0){
  28.             if(numberOfOnes==numberOfZeroes){
  29.                 cout<<"YES"<<endl;
  30.             }else if(numberOfZeroes%2==0 && numberOfOnes%2==0){
  31.                 cout<<"YES"<<endl;
  32.             }else{
  33.                 cout<<"NO"<<endl;
  34.             }
  35.         }else{
  36.             cout<<"YES"<<endl;
  37.         }
  38.        
  39.        
  40.     }
  41.     return 0;
  42. }
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement