codeforces 655A A. Amity Assessment(水题)

时间:2022-08-29 16:04:27

题目链接:

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:

codeforces 655A  A. Amity Assessment(水题)

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 ;
}

codeforces 655A A. Amity Assessment(水题)的更多相关文章

  1. CROC 2016 - Elimination Round &lpar;Rated Unofficial Edition&rpar; A&period; Amity Assessment 水题

    A. Amity Assessment 题目连接: http://www.codeforces.com/contest/655/problem/A Description Bessie the cow ...

  2. codeforces 577B B&period; Modulo Sum&lpar;水题&rpar;

    题目链接: B. Modulo Sum time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  3. Codeforces Round &num;367 &lpar;Div&period; 2&rpar;---水题 &vert; dp &vert; 01字典树

    A.Beru-taxi 水题:有一个人站在(sx,sy)的位置,有n辆出租车,正向这个人匀速赶来,每个出租车的位置是(xi, yi) 速度是 Vi;求人最少需要等的时间: 单间循环即可: #inclu ...

  4. codeforces 696A Lorenzo Von Matterhorn 水题

    这题一眼看就是水题,map随便计 然后我之所以发这个题解,是因为我用了log2()这个函数判断在哪一层 我只能说我真是太傻逼了,这个函数以前听人说有精度问题,还慢,为了图快用的,没想到被坑惨了,以后尽 ...

  5. CodeForces 589I Lottery &lpar;暴力,水题&rpar;

    题意:给定 n 和 k,然后是 n 个数,表示1-k的一个值,问你修改最少的数,使得所有的1-k的数目都等于n/k. 析:水题,只要用每个数减去n/k,然后取模,加起来除以2,就ok了. 代码如下: ...

  6. Codeforces Gym 100286G Giant Screen 水题

    Problem G.Giant ScreenTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/con ...

  7. codeforces 710A A&period; King Moves&lpar;水题&rpar;

    题目链接: A. King Moves 题意: 给出king的位置,问有几个可移动的位置; 思路: 水题,没有思路; AC代码: #include <iostream> #include ...

  8. codeforces 659A A&period; Round House&lpar;水题&rpar;

    题目链接: A. Round House time limit per test 1 second memory limit per test 256 megabytes input standard ...

  9. CodeForces 489B BerSU Ball (水题 双指针)

    B. BerSU Ball time limit per test 1 second memory limit per test 256 megabytes input standard input ...

随机推荐

  1. AC之路开始了~

    已经进行了半年ACM的学习啦~虽然实力很弱但是仍然快快乐乐的慢慢学习... 新建了我的博客~ 记录A题经验 感悟学习点滴~ 加油~

  2. ASP&period;NET访问Access的连接字符串配置

    由于Access是文件数据库,所以在ASP.NET需要能映射访问到Access文件: 方式一:appSettings中设置连接字符串 web.config的配置 <appSettings> ...

  3. Linux内核学习笔记——内核内存管理方式

    一 页 内核把物理页作为内存管理的基本单位:内存管理单元(MMU)把虚拟地址转换为物理 地址,通常以页为单位进行处理.MMU以页大小为单位来管理系统中的也表. 32位系统:页大小4KB 64位系统:页 ...

  4. Cocos2dx隐藏iOS7状态栏】通过添加Plist Key隐藏iOS7状态栏

    本站文章均为李华明Himi原创,转载务必在明显处注明:(作者新浪微博:@李华明Himi)  转载自[黑米GameDev街区] 原文链接: http://www.himigame.com/%e9%9a% ...

  5. ubuntu server编译安装nginx

    刚刚安装好了ubuntu server14.04,如今要安装一个webserver,纯静态就用nginx应用程序server吧,性能出众啊. 安装编译环境 我们这里採用源代码编译安装的方式,大家能够看 ...

  6. java String转int int转化为String

    String转int String str = "123"; int a = Integer.parseInt(str); System.out.println(a); Integ ...

  7. c&plus;&plus;文件的读写

    c++文件的读写 1.文本方式的写文件 #include <iostream> #include <fstream> using namespace std; int main ...

  8. tomcat环境多个jdk版本自定义使用JDK版本及路径

    windows环境: 多个应用使用tomcat并且有不同版本的jdk,为避免重复可以在启动文件中指定JDK的版本 如新安装的JDK6在C:\Program Files\Java\jdk1.7.0_79 ...

  9. ef 数据库连接字符串加密

    public testContext() : base(GetConnection(), true) { } public static DbConnection GetConnection() { ...

  10. 23&lowbar;pikle&sol;shevel&sol;json

    一.序列化       存储数据或者传输数据时,需要把对象进行处理,把对象处理成方便存储和传输的数据格式.不同的序列化,结果也不同.     序列化方式:         (1) pickle 可以将 ...