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