fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int t;
  6. cin >> t;
  7. while(t--){
  8. int n;
  9. cin >> n;
  10. int f[2] = {0, 0};
  11. vector<int>v;
  12. string s;
  13. cin >> s;
  14. for(int i=0; i<n; i++){
  15. v.push_back(s[i] - '0');
  16. if(v[i] == 0)f[0]++;
  17. else f[1]++;
  18. if(v[i] != v[i+1]){
  19. v.push_back(0);
  20. f[0]++;
  21. }
  22. }
  23. if(f[0] > f[1])cout << "YES";
  24. else cout << "NO";
  25. cout << endl;
  26. }
  27. return 0;
  28. }
Success #stdin #stdout 0s 5288KB
stdin
3
2
00
2
11
2
10
stdout
YES
YES
YES