Educational Codeforces Round 33 (Rated for Div. 2) A - Chess For Three
2017-11-24 22:15
429 查看
手动模拟
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<stack>
#include<map>
#define PI acos(-1.0)
#define in freopen("in.txt", "r", stdin)
#define out freopen("out.txt", "w", stdout)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int maxn = 100 + 7, maxd = 670000 + 7;
const ll mod = 1e9 + 7;
const int INF = 0x7f7f7f7f;
int main() {
ios::sync_with_stdio(0);
int n, x;
int a, b, c;
cin >> n ;
a = 1; b = 2; //c = 3;
for(int i = 0; i < n; ++i) {
cin >> x;
if(x == 1) {
if(a == 1) {
b = 5 - b;
}
else if(b == 1) {
a = 5 - a;
}
else return puts("NO")*0;
}
else if(x == 2) {
if(a == 2) {
b = 4 - b;
}
else if(b == 2) {
a = 4 - a;
}
else return puts("NO")*0;
}
else if(x == 3) {
if(a == 3) {
b = 3 - b;
}
else if(b == 3) {
a = 3 - a;
}
else return puts("NO")*0;
}
}
puts("YES");
return 0;
}
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<stack>
#include<map>
#define PI acos(-1.0)
#define in freopen("in.txt", "r", stdin)
#define out freopen("out.txt", "w", stdout)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int maxn = 100 + 7, maxd = 670000 + 7;
const ll mod = 1e9 + 7;
const int INF = 0x7f7f7f7f;
int main() {
ios::sync_with_stdio(0);
int n, x;
int a, b, c;
cin >> n ;
a = 1; b = 2; //c = 3;
for(int i = 0; i < n; ++i) {
cin >> x;
if(x == 1) {
if(a == 1) {
b = 5 - b;
}
else if(b == 1) {
a = 5 - a;
}
else return puts("NO")*0;
}
else if(x == 2) {
if(a == 2) {
b = 4 - b;
}
else if(b == 2) {
a = 4 - a;
}
else return puts("NO")*0;
}
else if(x == 3) {
if(a == 3) {
b = 3 - b;
}
else if(b == 3) {
a = 3 - a;
}
else return puts("NO")*0;
}
}
puts("YES");
return 0;
}
相关文章推荐
- Educational Codeforces Round 33 (Rated for Div. 2) A题. Chess For Three
- Educational Codeforces Round 33 (Rated for Div. 2)
- Educational Codeforces Round 33 (Rated for Div. 2)
- Educational Codeforces Round 33 (Rated for Div. 2) F. Subtree Minimum Query (线段树)
- Educational Codeforces Round 33 (Rated for Div. 2)
- Educational Codeforces Round 33 (Rated for Div. 2)【C】【并查集】
- Educational Codeforces Round 33 (Rated for Div. 2) A-C题解
- Educational Codeforces Round 33 (Rated for Div. 2)A-F
- Educational Codeforces Round 33 (Rated for Div. 2) B题. Beautiful Divisors
- Educational Codeforces Round 33 (Rated for Div. 2) B - Beautiful Divisors
- Educational Codeforces Round 33 (Rated for Div. 2) F - Subtree Minimum Query
- Educational Codeforces Round 33 (Rated for Div. 2)A-F
- Educational Codeforces Round 33 (Rated for Div. 2) C - Rumor
- 【Educational Codeforces Round 33 A】Chess For Three
- 【 Educational Codeforces Round 33 A】Chess For Three
- Educational Codeforces Round 33 (Rated for Div. 2) C
- codeforces Educational Codeforces Round 33 (Rated for Div. 2)B
- Educational Codeforces Round 33 (Rated for Div. 2) 题解
- Educational Codeforces Round 33 (Rated for Div. 2) D题. Credit Card(贪心)
- Educational Codeforces Round 33 (Rated for Div. 2) D. Credit Card