Secrete Master Plan

Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others)
Submit Status

Master Mind KongMing gave Fei Zhang a secrete master plan stashed in a pocket. The plan instructs how to deploy soldiers on the four corners of the city wall. Unfortunately, when Fei opened the pocket he found there are only four numbers written in dots on a piece of sheet. The numbers form a 2×22×2 matrix, but Fei didn't know the correct direction to hold the sheet. What a pity!

Given two secrete master plans. The first one is the master's original plan. The second one is the plan opened by Fei. As KongMing had many pockets to hand out, he might give Fei the wrong pocket. Determine if Fei receives the right pocket.

Input

The first line of the input gives the number of test cases, TT(1≤T≤1041≤T≤104). TT test cases follow. Each test case contains 44 lines. Each line contains two integers ai0ai0 and ai1ai1 (1≤ai0,ai1≤1001≤ai0,ai1≤100). The first two lines stands for the original plan, the 3rd3rd and 4th4th line stands for the plan Fei opened.

Output

For each test case, output one line containing Case #x: y, where xx is the test case number (starting from 11) and yy is either "POSSIBLE" or "IMPOSSIBLE" (quotes for clarity).

Sample input and output

Sample Input Sample Output
4
1 2
3 4
1 2
3 4 1 2
3 4
3 1
4 2 1 2
3 4
3 2
4 1 1 2
3 4
4 3
2 1
Case #1: POSSIBLE
Case #2: POSSIBLE
Case #3: IMPOSSIBLE
Case #4: POSSIBLE

Source

The 2015 China Collegiate Programming Contest

#include <iostream>
using namespace std;
int main()
{
int t,a,b,c,d,x,y,z,w,tmp,k=;
cin>>t;
while(t--)
{
int flag=;
cin>>a>>b>>d>>c;
cin>>x>>y>>w>>z;
while (a!=x||b!=y||d!=w||c!=z)
{
tmp=a;
a=b;
b=c;
c=d;
d=tmp;
flag++;
if (flag==)
break;
}
if (flag<)
{
cout<<"Case #"<<k++<<": POSSIBLE"<<endl;
}
else
cout<<"Case #"<<k++<<": IMPOSSIBLE"<<endl; }
return ;
}

UESTC 1215 (思维题 旋转)的更多相关文章

  1. 洛谷 P4749 - [CERC2017]Kitchen Knobs(差分转换+dp,思维题)

    题面传送门 一道挺有意思的思维题. 首先有一个 obvious 的结论,就是对于每个炉子,要么转到哪里都符合条件,要么存在唯一的最大值.对于转到哪儿都符合条件的炉子我们 duck 不必考虑它,故我们只 ...

  2. zoj 3778 Talented Chef(思维题)

    题目 题意:一个人可以在一分钟同时进行m道菜的一个步骤,共有n道菜,每道菜各有xi个步骤,求做完的最短时间. 思路:一道很水的思维题, 根本不需要去 考虑模拟过程 以及先做那道菜(比赛的时候就是这么考 ...

  3. cf A. Inna and Pink Pony(思维题)

    题目:http://codeforces.com/contest/374/problem/A 题意:求到达边界的最小步数.. 刚开始以为是 bfs,不过数据10^6太大了,肯定不是... 一个思维题, ...

  4. ZOJ 3829 贪心 思维题

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3829 现场做这道题的时候,感觉是思维题.自己智商不够.不敢搞,想着队友智商 ...

  5. 洛谷P4643 [国家集训队]阿狸和桃子的游戏(思维题+贪心)

    思维题,好题 把每条边的边权平分到这条边的两个顶点上,之后就是个sb贪心了 正确性证明: 如果一条边的两个顶点被一个人选了,一整条边的贡献就凑齐了 如果分别被两个人选了,一作差就抵消了,相当于谁都没有 ...

  6. C. Nice Garland Codeforces Round #535 (Div. 3) 思维题

    C. Nice Garland time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

  7. PJ考试可能会用到的数学思维题选讲-自学教程-自学笔记

    PJ考试可能会用到的数学思维题选讲 by Pleiades_Antares 是学弟学妹的讲义--然后一部分题目是我弄的一部分来源于洛谷用户@ 普及组的一些数学思维题,所以可能有点菜咯别怪我 OI中的数 ...

  8. UVA 1394 And Then There Was One / Gym 101415A And Then There Was One / UVAlive 3882 And Then There Was One / POJ 3517 And Then There Was One / Aizu 1275 And Then There Was One (动态规划,思维题)

    UVA 1394 And Then There Was One / Gym 101415A And Then There Was One / UVAlive 3882 And Then There W ...

  9. HDU 1029 Ignatius and the Princess IV / HYSBZ(BZOJ) 2456 mode(思维题,~~排序?~~)

    HDU 1029 Ignatius and the Princess IV (思维题,排序?) Description "OK, you are not too bad, em... But ...

随机推荐

  1. BZOJ-1705 Longge的问题 一维GCD SUM 乱搞+质因数分解+...

    2705: [SDOI2012]Longge的问题 Time Limit: 3 Sec Memory Limit: 128 MB Submit: 1871 Solved: 1172 [Submit][ ...

  2. BZOJ-1861 Book 书架 Splay

    1861: [Zjoi2006]Book 书架 Time Limit: 4 Sec Memory Limit: 64 MB Submit: 1010 Solved: 588 [Submit][Stat ...

  3. Angulajs系列-01-入门

    1.解决什么问题? a, controller的各种的创建 b,体验angular的双向绑定 2.怎么解决 2.1 引入angularjs 下载地址 2.2 创建controller的方法 2.2.1 ...

  4. BZOJ1034 [ZJOI2008]泡泡堂BNB

    Description 第XXXX届NOI期间,为了加强各省选手之间的交流,组委会决定组织一场省际电子竞技大赛,每一个省的代表 队由n名选手组成,比赛的项目是老少咸宜的网络游戏泡泡堂.每一场比赛前,对 ...

  5. c++内存分配(new和delete)

    c中malloc和free是函数,包含在stdlib.h头文件中,分配成功返回指针,失败返回空指针. 与new的区别是: 1,malloc与free是C++/C语言的标准库函数,new/delete是 ...

  6. 基于REST架构的Web Service设计

    来自: http://www.williamlong.info/archives/1728.html 先前我曾经介绍过利用Apache Axis实现基于SOAP的Web Service实现技术和相关代 ...

  7. IIS短文件名泄露漏洞危害及防范方法

    危害级别:轻微 IIS短文件名泄露漏洞 WASC Threat Classification 描述: Microsoft IIS在实现上存在文件枚举漏洞,攻击者可利用此漏洞枚举网络服务器根目录中的文件 ...

  8. mysql cluster (mysql 集群)安装配置方案(转)

    一.准备 1.准备服务器 计划建立有5个节点的MySQL CLuster体系,需要用到5台服务器,但是我们做实验时没有这么多机器,可以只用2台,我就是一台本机,一台虚拟机搭建了有5个节点的MySQL ...

  9. C# 根据IP地址获取城市

    using System; using System.IO; using System.Net; using System.Text; using System.Web.Script.Serializ ...

  10. Visual Studio 2013 中 mysql 使用 EF6

    1.web.config <configSections> <!-- For more information on Entity Framework configuration, ...