codeforces 655A A. Amity Assessment(水题)
题目链接:
2 seconds
256 megabytes
standard input
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.
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 "YES"(without quotes) if the puzzles can reach the same configuration (and Bessie and Elsie are truly BFFLs). Otherwise, print "NO" (without quotes).
AB
XC
XB
AC
YES
AB
XC
AC
BX
NO
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(水题)的更多相关文章
- CROC 2016 - Elimination Round (Rated Unofficial Edition) A. Amity Assessment 水题
A. Amity Assessment 题目连接: http://www.codeforces.com/contest/655/problem/A Description Bessie the cow ...
- codeforces 577B B. Modulo Sum(水题)
题目链接: B. Modulo Sum time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Round #367 (Div. 2)---水题 | dp | 01字典树
A.Beru-taxi 水题:有一个人站在(sx,sy)的位置,有n辆出租车,正向这个人匀速赶来,每个出租车的位置是(xi, yi) 速度是 Vi;求人最少需要等的时间: 单间循环即可: #inclu ...
- codeforces 696A Lorenzo Von Matterhorn 水题
这题一眼看就是水题,map随便计 然后我之所以发这个题解,是因为我用了log2()这个函数判断在哪一层 我只能说我真是太傻逼了,这个函数以前听人说有精度问题,还慢,为了图快用的,没想到被坑惨了,以后尽 ...
- CodeForces 589I Lottery (暴力,水题)
题意:给定 n 和 k,然后是 n 个数,表示1-k的一个值,问你修改最少的数,使得所有的1-k的数目都等于n/k. 析:水题,只要用每个数减去n/k,然后取模,加起来除以2,就ok了. 代码如下: ...
- Codeforces Gym 100286G Giant Screen 水题
Problem G.Giant ScreenTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/con ...
- codeforces 710A A. King Moves(水题)
题目链接: A. King Moves 题意: 给出king的位置,问有几个可移动的位置; 思路: 水题,没有思路; AC代码: #include <iostream> #include ...
- codeforces 659A A. Round House(水题)
题目链接: A. Round House time limit per test 1 second memory limit per test 256 megabytes input standard ...
- CodeForces 489B BerSU Ball (水题 双指针)
B. BerSU Ball time limit per test 1 second memory limit per test 256 megabytes input standard input ...
随机推荐
- COM线程单元
节选自C#高级编程 不管是单线程单元还是多线程单元,一个线程只能属于一个单元. 1) 单线程单元(apartment, 寓所,套间) 单线程单元与它拥有的线程是一对一的关系.COM对象在编写时不是线程 ...
- 【BZOJ3698】XWW的难题 有上下界的最大流
[BZOJ3698]XWW的难题 Description XWW是个影响力很大的人,他有很多的追随者.这些追随者都想要加入XWW教成为XWW的教徒.但是这并不容易,需要通过XWW的考核.XWW给你出了 ...
- EasyNVR、EasyDSS二次开发之:RTMP、HLS流在web页面进行无插件播放示例Demo代码
不管是基于EasyNVR还是EasyDSS,都是支持无插件直播,这也是未来视频直播的一个趋势.对于传统的浏览器插件播放谁用谁知道: 以上是软件自带播放展示 背景需求 对于EasyNVR和EasyDSS ...
- 解决 SVN版本冲突
链接:http://blog.csdn.net/windone0109/article/details/4857044 版本冲突原因: 假设A.B两个用户都在版本号为100的时候,更新了kingtun ...
- debian安装oracle jdk
1 去官网下载linux jdk https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.htm ...
- [php]Maximum function nesting level of '100' reached错误
今天在做后台一个模块的时候报出了这个错误. Maximum function nesting level of '100' reached 仔细分析之后发现是在类的初始化过程中(__construct ...
- 【模式识别】CART和GML AdaBoost MATLAB TOOLBOX
GML AdaBoost Matlab Toolbox是一款很优秀的AdaBoost工具箱,内部实现了Real AdaBoost, Gentle AdaBoost和Modest AdaBoost三种方 ...
- 图片的等比缩放和Logo水印
/** * 等比缩放函数(以保存的方式实现) * @param string $picname 被缩放的处理图片源 * @param int $maxx 缩放后图片的最大宽度 * @param int ...
- iOS 尝试用 block 闭包 去代替delegate 实现方法
通常都是这样创建alert 再加一个代理 // 创建一个UIAlertView并显示出来 UIAlertView *alertview = [[UIAlertView alloc] initWithT ...
- oracle 序列 + 触发器 实现 ID自动增长
1.创建序列 create sequence emp_sequence increment by ----每次增加几个 minvalue ----最小值为1 nomaxvalue----不限制最大值 ...