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 ...
随机推荐
- sql exist 优化查询时间
1.非exist,查询需要20多秒 2.使用exist后 3.表连接也能优化
- Effective C++ 49,50
49.熟悉标准库. C++标准库非常大. 首先标准库中函数非常多,为了避免名字冲突.使用命名空间std.而之前的库函数都存放于< .h>中,如今成为伪标准库.而不能直接将这些头文件所有直接 ...
- iphone开发技术要学习的内容
一.iOS基础 1 开发环境搭建以及IOS组件.框架的概要介绍. 2 mac操作系统与iOS操作系统 3 xcode IDE开发环境的初始 二.C语言基础 1数据类型.表达式与控制流程语句 2数组.函 ...
- iOS流布局UICollectionView系列七——三维中的球型布局
摘要: 类似标签云的球状布局,也类似与魔方的3D布局 iOS流布局UICollectionView系列七——三维中的球型布局 一.引言 通过6篇的博客,从平面上最简单的规则摆放的布局,到不规则的瀑 ...
- python第三方库地址
python第三方库的地址: requests: http://docs.python-requests.org/zh_CN/latest/user/quickstart.html beautifus ...
- python函数-------python2.7教程学习【廖雪峰版】(三)
任务: 看完函数这一章 已完成 2017年6月8日16:23:491.函数的作用:写较少的代码实现较多的功能,可以多次被调用.2.可见,借助抽象,我们才能不关心底层的具体计算过程,而直接在更高的 ...
- JSP具体篇——application
application对象 application对象用于保存全部应用程序中的共同拥有数据.它在server启动时自己主动创建.在server停止时自己主动销毁. 当application对象没有被销 ...
- 在UIWebView中设置cookie
本文转载至 http://blog.csdn.net/chengyakun11/article/details/8863878 项目中,需要在打开3g网页时,通过cookie传递一些信息. 实现代码 ...
- 快捷标签和ajax、json返回数据
<if 判断条件>标签</if><import>标签可以链接外部的样式表,和js<import file="js.util.Array" ...
- codevs 必做:2776、1222
2776 寻找代表元 时间限制: 1 s 空间限制: 256000 KB 题目等级 : 黄金 Gold 题解 题目描述 Description 广州二中苏元实验学校一共有n个社团,分 ...