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 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 a 2 × 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).
Sample Input
AB
XC
XB
AC
Sample Output
YES
Hint
题意
类似于华容道一样,一个2*2的格子,然后问你能不能从第一个推到第二个
题解:
由于是2*2的,我们比较简单的就可以发现,其实他按照顺时针\逆时针的顺序是不会改变的。
所以只用check一下顺序就好了。
代码
#include<bits/stdc++.h>
using namespace std;
string s1,s2;
int main()
{
string a,b,c,d;
cin>>a>>b>>c>>d;
for(int i=0;i<2;i++)
if(a[i]!='X')s1+=a[i];
for(int i=1;i>=0;i--)
if(b[i]!='X')s1+=b[i];
for(int i=0;i<2;i++)
if(c[i]!='X')s2+=c[i];
for(int i=1;i>=0;i--)
if(d[i]!='X')s2+=d[i];
s1+=s1;
if(s1.find(s2)!=string::npos)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
CROC 2016 - Elimination Round (Rated Unofficial Edition) A. Amity Assessment 水题的更多相关文章
- CROC 2016 - Elimination Round (Rated Unofficial Edition) D. Robot Rapping Results Report 二分+拓扑排序
D. Robot Rapping Results Report 题目连接: http://www.codeforces.com/contest/655/problem/D Description Wh ...
- CROC 2016 - Elimination Round (Rated Unofficial Edition) D. Robot Rapping Results Report 拓扑排序+二分
题目链接: http://www.codeforces.com/contest/655/problem/D 题意: 题目是要求前k个场次就能确定唯一的拓扑序,求满足条件的最小k. 题解: 二分k的取值 ...
- CROC 2016 - Elimination Round (Rated Unofficial Edition) F - Cowslip Collections 数论 + 容斥
F - Cowslip Collections http://codeforces.com/blog/entry/43868 这个题解讲的很好... #include<bits/stdc++.h ...
- CROC 2016 - Elimination Round (Rated Unofficial Edition) E - Intellectual Inquiry dp
E - Intellectual Inquiry 思路:我自己YY了一个算本质不同子序列的方法, 发现和网上都不一样. 我们从每个点出发向其后面第一个a, b, c, d ...连一条边,那么总的不同 ...
- CROC 2016 - Elimination Round (Rated Unofficial Edition) E. Intellectual Inquiry 贪心 构造 dp
E. Intellectual Inquiry 题目连接: http://www.codeforces.com/contest/655/problem/E Description After gett ...
- CROC 2016 - Elimination Round (Rated Unofficial Edition) C. Enduring Exodus 二分
C. Enduring Exodus 题目连接: http://www.codeforces.com/contest/655/problem/C Description In an attempt t ...
- CROC 2016 - Elimination Round (Rated Unofficial Edition) B. Mischievous Mess Makers 贪心
B. Mischievous Mess Makers 题目连接: http://www.codeforces.com/contest/655/problem/B Description It is a ...
- 8VC Venture Cup 2016 - Final Round (Div. 2 Edition)B. sland Puzzle 水题
B. sland Puzzle 题目连接: http://www.codeforces.com/contest/635/problem/B Description A remote island ch ...
- CF #CROC 2016 - Elimination Round D. Robot Rapping Results Report 二分+拓扑排序
题目链接:http://codeforces.com/contest/655/problem/D 大意是给若干对偏序,问最少需要前多少对关系,可以确定所有的大小关系. 解法是二分答案,利用拓扑排序看是 ...
随机推荐
- Windows下Oracle数据库自动备份批处理脚本
expdb命令版本 @echo off REM ########################################################### REM # Windows Se ...
- html基础-css-选择器
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...
- webservice使用
soap方法 一:PHP本身的SOAP 所有的webservice都包括服务端(server)和客户端(client). 要使用php本身的soap首先要把该拓展安装好并且启用.下面看具体的code ...
- SNMP AGENT函数介绍
http://wenku.baidu.com/view/6a7903a9d1f34693daef3e9f.html 一. SNMP AGENT在SNMP框架中的位置 1.1 SNMP是被广泛接受并投 ...
- HDU 2544 最短路(floyd+bellman-ford+spfa+dijkstra队列优化)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2544 题目大意:找点1到点n的最短路(无向图) 练一下最短路... dijkstra+队列优化: #i ...
- mongodb与mysql传统的关系数据库区别
转自:易百教程 MongoDB中的数据具有灵活的模式.文档在同一集合,但它们不需要具有相同的字段或结构集合,集合文档中的公共字段可以包含不同类型的数据. MongoDB中的数据具有灵活的模式.与SQL ...
- 洛谷 P2043质因子分解 题解
题目传送门 N的范围很小,所以使用O(n2)的算法就能过啦! #include<bits/stdc++.h> using namespace std; ],n; int main(){ c ...
- Visual Studio 中如何同时注释多行和取消注释多行
注释多行:先按 Ctrl - K 组合键,再按 Ctrl - C 组合键 取消注释多行:先按 Ctrl - K 组合键,再按 Ctrl - U 组合键
- CentOS7.6使用flatpak安装软件
1.安装flatpak(CentOS 7已默认安装Flatpak) yum -y install flatpak 2.添加Flathub仓库 flatpak remote-add --if-not-e ...
- Https 请求工具(put,post,get)
package com.util; /** * @Description: 类描述 * @author 作者 ll E-mail:80002132@sf-express.com * @version ...