#include <iostream>
using namespace std;

int main() {
    int n, ans = 0, direction = 0;
    cin >> n;
    while (n--) {
        int command;
        cin >> command;
        if (command == 0) {
            direction = (direction + 1) % 4;
        }
        else if (command == 1) {
            direction = (direction + 3) % 4;
        }
        else {
            direction = (direction + 2) % 4;
        }
        if (direction == 0) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}
``

原文地址: https://www.cveoy.top/t/topic/cZhp 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录