fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. ios::sync_with_stdio(false);
  6. cin.tie(0);
  7. int t;
  8. cin >> t;
  9. while (t--) {
  10. int n;
  11. cin >> n;
  12. string s;
  13. cin >> s;
  14. int up = 0;
  15. for (char c : s) {
  16. if (c == 'U') up++;
  17. }
  18. if (up % 2 == 0) {
  19. cout << "NO\n";
  20. } else {
  21. cout << "YES\n";
  22. }
  23. }
  24. return 0;
  25. }
Success #stdin #stdout 0.01s 5304KB
stdin
3
5
UUDUD
5
UDDUD
2
UU
stdout
YES
NO
NO