题目链接:

A. Amity Assessment

time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

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 a2 × 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).

Examples
input
AB
XC
XB
AC
output
YES
input
AB
XC
AC
BX
output
NO
Note

The solution to the first sample is described by the image. All Bessie needs to do is slide her 'A' tile down.

In the second sample, the two puzzles can never be in the same configuration. Perhaps Bessie and Elsie are not meant to be friends after all...

题意:问给你两种状态问是否能由第一种状态转化成第二种;

思路:顺时针方向的顺序看是否符合;

AC代码:

#include <bits/stdc++.h>
using namespace std;
int main()
{
char a[][],b[][],ans1[],ans2[];
scanf("%s",a[]);
scanf("%s",a[]);
scanf("%s",b[]);
scanf("%s",b[]);
int cnt=,num=;
if(a[][]!='X')ans1[cnt++]=a[][];
if(a[][]!='X')ans1[cnt++]=a[][];
if(a[][]!='X')ans1[cnt++]=a[][];
if(a[][]!='X')ans1[cnt++]=a[][];
if(b[][]!='X')ans2[num++]=b[][];
if(b[][]!='X')ans2[num++]=b[][];
if(b[][]!='X')ans2[num++]=b[][];
if(b[][]!='X')ans2[num++]=b[][];
int n=;
while(n--){
if(ans1[]==ans2[]&&ans1[]==ans2[]&&ans1[]==ans2[])
{
cout<<"YES"<<"\n";
return ;
}
else
{
char m=ans2[];
for(int i=;i<;i++)
{
ans2[i]=ans2[i+];
}
ans2[]=m;
}
}
cout<<"NO"<<endl;
return ;
}

最新文章

  1. Vue.js:轻量高效的前端组件化方案(转载)
  2. java参数传递时到底是值传递还是引用传递
  3. 事件分发&amp;响应链
  4. lambda语法
  5. java设计模式之观察者模式(9)
  6. Spring(二)--FactoryBean、bean的后置处理器、数据库连接池、引用外部文件、使用注解配置bean等
  7. 提高PHP性能的一些小知识
  8. IOS开发之App被拒原因
  9. 【Storm篇】--Storm基础概念
  10. 《两地书》--Kubernetes(K8s)基础知识(docker容器技术)
  11. iOS---------显示和隐藏状态栏的网络活动标志
  12. 在U8菜单中增加自定义项
  13. springboot整合mybatics PLUS
  14. 【倍增】T-shirt @2018acm徐州邀请赛 I
  15. python的var_dump,打印对象内容
  16. elasticsearch-权威指南笔记-基础部分
  17. 正则js
  18. 7.12 Models -- Frequently Asked Questions
  19. 2014.1.4 cxf spring webservice
  20. ISP (互联网服务提供商)

热门文章

  1. 使用badboy录制脚本 结合Jmeter一起测试。
  2. 关于iphone自动播放音频和视频问题的解决办法
  3. 地形混合shader
  4. Android ImageButton的使用。
  5. python tensorflow 安装
  6. 将非递减有序排列(L L1)归并为一个新的线性表L2 线性表L2中的元素仍按值非递减
  7. Nginx结合GeoIP库
  8. Activiti使用过程_1
  9. date_default_timezone_get():
  10. JVM性能优化, Part 3 垃圾回收