fork download
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  6.  
  7. string s;
  8. cin >> s;
  9. bool flag = true;
  10. for (int i = 0; i < s.size(); i++) {
  11. if (i % 2 == 0) {
  12. if (s[i] != 'D' && s[i] != 'U' && s[i] != 'L') {
  13. flag = false;
  14. break;
  15. }
  16. } else {
  17. if (s[i] != 'D' && s[i] != 'U' && s[i] != 'R') {
  18. flag = false;
  19. break;
  20. }
  21. }
  22. }
  23.  
  24. if (flag) {
  25. cout << "Yes" << "\n";
  26. } else {
  27. cout << "No" << "\n";
  28. }
  29.  
  30. return 0;
  31. }
  32.  
  33.  
  34.  
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
Yes