A. Amity Assessment

题目连接:

http://www.codeforces.com/contest/655/problem/A

Description

Bessie the cow and her best friend Elsie each received a sliding puzzle on Pi Day. Their puzzles consist of a 2 × 2 grid and three tiles labeled 'A', 'B', and 'C'. The three tiles sit on top of the grid, leaving one grid cell empty. To make a move, Bessie or Elsie can slide a tile adjacent to the empty cell into the empty cell as shown below:

In order to determine if they are truly Best Friends For Life (BFFLs), Bessie and Elsie would like to know if there exists a sequence of moves that takes their puzzles to the same configuration (moves can be performed in both puzzles). Two puzzles are considered to be in the same configuration if each tile is on top of the same grid cell in both puzzles. Since the tiles are labeled with letters, rotations and reflections are not allowed.

Input

The first two lines of the input consist of a 2 × 2 grid describing the initial configuration of Bessie's puzzle. The next two lines contain a 2 × 2 grid describing the initial configuration of Elsie's puzzle. The positions of the tiles are labeled 'A', 'B', and 'C', while the empty cell is labeled 'X'. It's guaranteed that both puzzles contain exactly one tile with each letter and exactly one empty position.

Output

Output "YES"(without quotes) if the puzzles can reach the same configuration (and Bessie and Elsie are truly BFFLs). Otherwise, print "NO" (without quotes).

Sample Input

AB

XC

XB

AC

Sample Output

YES

Hint

题意

类似于华容道一样,一个2*2的格子,然后问你能不能从第一个推到第二个

题解:

由于是2*2的,我们比较简单的就可以发现,其实他按照顺时针\逆时针的顺序是不会改变的。

所以只用check一下顺序就好了。

代码

#include<bits/stdc++.h>
using namespace std; string s1,s2; int main()
{
string a,b,c,d;
cin>>a>>b>>c>>d;
for(int i=0;i<2;i++)
if(a[i]!='X')s1+=a[i];
for(int i=1;i>=0;i--)
if(b[i]!='X')s1+=b[i];
for(int i=0;i<2;i++)
if(c[i]!='X')s2+=c[i];
for(int i=1;i>=0;i--)
if(d[i]!='X')s2+=d[i];
s1+=s1;
if(s1.find(s2)!=string::npos)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}

CROC 2016 - Elimination Round (Rated Unofficial Edition) A. Amity Assessment 水题的更多相关文章

  1. CROC 2016 - Elimination Round (Rated Unofficial Edition) D. Robot Rapping Results Report 二分+拓扑排序

    D. Robot Rapping Results Report 题目连接: http://www.codeforces.com/contest/655/problem/D Description Wh ...

  2. CROC 2016 - Elimination Round (Rated Unofficial Edition) D. Robot Rapping Results Report 拓扑排序+二分

    题目链接: http://www.codeforces.com/contest/655/problem/D 题意: 题目是要求前k个场次就能确定唯一的拓扑序,求满足条件的最小k. 题解: 二分k的取值 ...

  3. CROC 2016 - Elimination Round (Rated Unofficial Edition) F - Cowslip Collections 数论 + 容斥

    F - Cowslip Collections http://codeforces.com/blog/entry/43868 这个题解讲的很好... #include<bits/stdc++.h ...

  4. CROC 2016 - Elimination Round (Rated Unofficial Edition) E - Intellectual Inquiry dp

    E - Intellectual Inquiry 思路:我自己YY了一个算本质不同子序列的方法, 发现和网上都不一样. 我们从每个点出发向其后面第一个a, b, c, d ...连一条边,那么总的不同 ...

  5. CROC 2016 - Elimination Round (Rated Unofficial Edition) E. Intellectual Inquiry 贪心 构造 dp

    E. Intellectual Inquiry 题目连接: http://www.codeforces.com/contest/655/problem/E Description After gett ...

  6. CROC 2016 - Elimination Round (Rated Unofficial Edition) C. Enduring Exodus 二分

    C. Enduring Exodus 题目连接: http://www.codeforces.com/contest/655/problem/C Description In an attempt t ...

  7. CROC 2016 - Elimination Round (Rated Unofficial Edition) B. Mischievous Mess Makers 贪心

    B. Mischievous Mess Makers 题目连接: http://www.codeforces.com/contest/655/problem/B Description It is a ...

  8. 8VC Venture Cup 2016 - Final Round (Div. 2 Edition)B. sland Puzzle 水题

    B. sland Puzzle 题目连接: http://www.codeforces.com/contest/635/problem/B Description A remote island ch ...

  9. CF #CROC 2016 - Elimination Round D. Robot Rapping Results Report 二分+拓扑排序

    题目链接:http://codeforces.com/contest/655/problem/D 大意是给若干对偏序,问最少需要前多少对关系,可以确定所有的大小关系. 解法是二分答案,利用拓扑排序看是 ...

随机推荐

  1. 【Python学习】使用BeautifulSoup解析HTML

    对于一个最简单的爬虫结构的代码是这样的. 也就是抓取出整个页面,然后创建一个BeautifulSoup对象. from urllib.request import urlopen from bs4 i ...

  2. git常用命令速查表【转】

  3. ip_rcv && ip_rcv_finish

    (1) 在inet_init中注册了类型为ETH_P_IP协议的数据包的回调ip_rcv (2) 当二层数据包接收完毕,会调用netif_receive_skb根据协议进行向上层分发 (3) 类型为E ...

  4. 内存不够清理方法,costdown项目时如果裁剪不下来,也可以参考

    Linux下清理内存和Cache方法 /proc/sys/vm/drop_caches 频繁的文件访问会导致系统的Cache使用量大增 $ free -m total used free shared ...

  5. SurfaceFlinger 讲解

    SurfaceFlinger是Android multimedia的一个部分,在Android 的实现中它是一个service,提供系统 范围内的surface composer功能,它能够将各种应用 ...

  6. C++ 模版的优点和缺点

    优点: 1. 灵活性, 可重用性和可扩展性; 2. 可以大大减少开发时间,模板可以把用同一个算法去适用于不同类型数据,在编译时确定具体的数据类型; 3. 模版模拟多态要比C++类继承实现多态效率要高, ...

  7. [写出来才有价值系列:node.js]node.js 02-,learnyounode

    安装learnyounode: npm install g learnyounode 官方说直接 但是我发现不行,很慢几乎就是死在那里了 还好有淘宝的东西给我们用https://npm.taobao. ...

  8. Java学习笔记()ArrayList

    1.什么是ArrayList ArrayList就是传说中的动态数组,用MSDN中的说法,就是Array的复杂版本,它提供了如下一些好处: 动态的增加和减少元素 实现了ICollection和ILis ...

  9. GLASNICI 解题报告

    GLASNICI 解题报告 题目描述 有N个人在一直线上,第i个人的位置为Di,满足Di≤Di+1.最初只有第1个人(在最左边)知道消息. 在任意时刻,每个人可以以每秒1单位的速度向左或向右移动,或者 ...

  10. jmeter------线程组(默认)

    Jmeter中的采样器必须要基于线程组. 一.添加线程组 在测试计划上右键,然后选择,如下图: 二.线程组界面 三.线程组界面配置说明 1.名称:线程组自定义名称: 2.注释:添加的一些备注说明信息, ...