Problem Description
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 2×2

 
Input
The first line of the input gives the number of test cases, T(1≤T≤104)Tai0ai11≤ai0,ai1≤1003rd4th
 
Output
For each test case, output one line containing "Case #x: y", where x is the test case number
(starting from 1) and y
 
Sample Input
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
 
Sample Output
Case #1: POSSIBLE
Case #2: POSSIBLE
Case #3: IMPOSSIBLE
Case #4: POSSIBLE
 #include<bits/stdc++.h>
using namespace std;
/*
方块旋转,两个矩形,如果能够通过旋转使两个一样则输出 possible
否则则输出impossible
*/
int A[][],B[][]; //矩阵A,矩阵B
//判断现两个矩形是否一样
bool Judge()
{
for(int i = ; i < ; i++)
for(int j = ; j < ; j++)
if(A[i][j] != B[i][j])
return false;
return true;
}
//将一个矩形进行旋转,顺时针旋转,
//破点:将[0][0]先后进行向左、斜方向、向下交换
void Swap()
{
swap(A[][],A[][]);
swap(A[][],A[][]);
swap(A[][],A[][]);
}
//通过旋转四次进行判定是否满足题意
bool Solve()
{
for(int i = ; i < ; i++)
{
if(Judge())
return true;
else
Swap();
}
return false;
} int main()
{
int T,n;
while(~scanf("%d",&T))
{
for(int p= ; p <= T; p++)
{ scanf("%d %d %d %d",&A[][],&A[][],&A[][],&A[][]);
scanf("%d %d %d %d",&B[][],&B[][],&B[][],&B[][]);
printf("Case #%d: ",p);
if(Solve())
{
printf("POSSIBLE\n");
}
else
{
printf("IMPOSSIBLE\n");
} }
}
return ;
}

ACM Secrete Master Plan的更多相关文章

  1. The 2015 China Collegiate Programming Contest A. Secrete Master Plan hdu5540

    Secrete Master Plan Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Othe ...

  2. 2015南阳CCPC A - Secrete Master Plan 水题

    D. Duff in Beach Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 无 Description Master Mind KongMing gave ...

  3. hdu 5540 Secrete Master Plan(水)

    Problem Description Master Mind KongMing gave Fei Zhang a secrete master plan stashed × matrix, but ...

  4. HDU-5540 Secrete Master Plan

    Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission( ...

  5. 2015南阳CCPC A - Secrete Master Plan A.

    D. Duff in Beach Description Master Mind KongMing gave Fei Zhang a secrete master plan stashed in a ...

  6. ACM学习历程—UESTC 1215 Secrete Master Plan(矩阵旋转)(2015CCPC A)

    题目链接:http://acm.uestc.edu.cn/#/problem/show/1215 题目大意就是问一个2*2的矩阵能否通过旋转得到另一个. 代码: #include <iostre ...

  7. HDOJ5540 Secrete Master Plan

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5540 题目大意:给一个两个2*2的矩阵,第二个矩阵能不能通过旋转得到第一个矩阵 题目思路:模拟 #in ...

  8. UESTC 1215 (思维题 旋转)

    Secrete Master Plan Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Othe ...

  9. CCPC A(模拟)

    Secrete Master Plan Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Othe ...

随机推荐

  1. JavaScript的对象/下

    JavaScript的对象 一.BOM对象 BOM----browser object model 1.window对象 所有浏览器都支持window对象. 概念上讲,一个html文档对应一个wind ...

  2. SpringBoot(一):使用eclipse/idea创建springboot helloword工程

    eclipse如何创建spring boot工程: 第一步:首先打开eclipse,找到图中的下图的中“下三角”符号,选中"working sets"(表示将会把eclipse中的 ...

  3. AWS stolen CPU

    故事的开头是这样的: 一天我正在吃饭,突然就收到了服务器告警(cpu high load),吓的我饭也没吃好,只吃了三碗就回去处理故障了,我在监控上看到了这样子的图: 看见了吧,吃饭那段时间cpu一下 ...

  4. 使用requirejs来管理angularJS依赖示例

    有关requirejs是什么在这里不做解释,只用纯代码实战让你感受requirejs依赖管理的强大. 一.首先要先下载require.js,然后整一个入口文件main.js包括了对其他js的引用. / ...

  5. 线程的同步控制(Synchronization)

    临界区(Critical Sections) 摘要 临界区(Critical Section) 用来实现"排他性占有".适合范围时单一进程的各线程之间. 特点 一个局部对象,不是一 ...

  6. 【推荐】CentOS安装gcc-4.9.4+更新环境+更新动态库

    注:以下所有操作均在CentOS 6.8 x86_64位系统下完成. CentOS上yum安装的gcc版本过低(4.4.7),在安装某些软件的时候不支持,所以这里需要对其进行升级. #gcc的安装# ...

  7. [LeetCode] Convert BST to Greater Tree 将二叉搜索树BST转为较大树

    Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original B ...

  8. Mlecms 反射型xss && 后台任意文件下载

    应该算0day吧,自己分析出来的,有点鸡肋,不过小cms分析确实比较简单. xss地址:search.php?word=a><img+src=1+onerror=alert`1`>a ...

  9. ognl版本错误

    错误信息: 2014-2-6 21:20:10 org.apache.catalina.core.StandardWrapperValve invoke严重: Servlet.service() fo ...

  10. [JLOI2015]装备购买

    题目描述 脸哥最近在玩一款神奇的游戏,这个游戏里有 n 件装备,每件装备有 m 个属性,用向量zi(aj ,.....,am) 表示 (1 <= i <= n; 1 <= j < ...