よじろめ覚書

私の理解度重視のソースコードです。

ABC141B - Tap Dance

問題:B - Tap Dance

#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(void) {
    const string odd = "RUD", even = "LUD";
    string s;
    bool flg = true;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    REP(i, s.length()) {
        if (i % 2 == 0 && odd.find(s[i]) != string::npos) {
            continue;
        } else if (i % 2 == 1 && even.find(s[i]) != string::npos) {
            continue;
        } else {
            flg = false;
        }
    }

    cout << (flg? "Yes" : "No") << "\n";
    return 0;
}