codeforces 893A Chess For Three 模拟

893A Chess For Three

思路:

直接模拟即可,第一盘永远是A与B开始

代码:

#include <bits/stdc++.h>
using namespace std;
#define _for(i,a,b) for(int i=(a); i<(b); ++i)
#define _rep(i,a,b) for(int i=(a); i<=(b); ++i)
int n,num,a[4];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    _rep(i,1,3) a[i]=i;
    _rep(i,1,n) {
        cin>>num;
        if(a[1]!=num&&a[2]!=num) {
            cout<<"NO"<<endl;
            return 0;
        }
        if(a[1]==num) {
            swap(a[2],a[3]);
        } else {
            swap(a[1],a[3]);
        }
    }
    cout<<"YES"<<endl;
    return 0;
}
原文地址:https://www.cnblogs.com/lemonbiscuit/p/7897184.html