codeforces croc2016 A. Amity Assessment (暴力)
题目链接 题意:2×2的格子,有三个位置分别放”A“ “B” “C” ,一个位置为空。只有和空位相邻位置上的字母能移动到空位。没有其他移动规则。现在给出两个状态。问能否互相转化。 思路: 貌似可以dfs…?但是一共才2*2,可以直接暴力枚举。 手写一种变换最多能有12种。
1/* ***********************************************
2Author :111qqz
3Created Time :2016年03月19日 星期六 00时21分02秒
4File Name :code/cf/croc2016/A.cpp
5************************************************ */
6
7#include <cstdio>
8#include <cstring>
9#include <iostream>
10#include <algorithm>
11#include <vector>
12#include <queue>
13#include <set>
14#include <map>
15#include <string>
16#include <cmath>
17#include <cstdlib>
18#include <ctime>
19#define fst first
20#define sec second
21#define lson l,m,rt<<1
22#define rson m+1,r,rt<<1|1
23#define ms(a,x) memset(a,x,sizeof(a))
24typedef long long LL;
25#define pi pair < int ,int >
26#define MP make_pair
27
28using namespace std;
29const double eps = 1E-8;
30const int dx4[4]={1,0,0,-1};
31const int dy4[4]={0,-1,1,0};
32const int inf = 0x3f3f3f3f;
33string a,b,c,d;
34int kind (string a,string b)
35{
36 if (a=="AB") return 1;
37 if (a=="BC") return 1;
38 if (a=="CA") return 1;
39 if (b=="AC") return 1;
40 if (b=="BA") return 1;
41 if (b=="CB") return 1;
42
43 return 2;
44}
45int main()
46{
47 #ifndef ONLINE_JUDGE
48 freopen("code/in.txt","r",stdin);
49 #endif
50 cin>>a>>b>>c>>d;
51 int p = kind(a,b);
52 int q = kind(c,d);
53 if (p==q)
54 {
55 puts("YES");
56 }
57 else
58 {
59 puts("NO");
60 }
61
62
63 #ifndef ONLINE_JUDGE
64 fclose(stdin);
65 #endif
66 return 0;
67}