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. django Form组件

    django Form组件 Django的Form主要具有一下几大功能: 生成HTML标签 验证用户数据(显示错误信息) HTML Form提交保留上次提交数据 初始化页面显示内容 小试牛刀 1.创建 ...

  2. Apache Spark Jobs 性能调优

    当你开始编写 Apache Spark 代码或者浏览公开的 API 的时候,你会遇到各种各样术语,比如transformation,action,RDD(resilient distributed d ...

  3. MySQL高可用架构之MHA 原理与实践

    MHA简介 关于MHA MHA(Master HA)是一款开源的MySQL的高可用程序,它为MySQL主从复制架构提供了automating master failover 功能.MHA在监控到mas ...

  4. MySQL协议学习(1):准备工作

    MySQL Client/Server协议 准确的说应该是MySQL Client/Server协议,另一个叫X Protocol的暂不涉及.地址如下:MySQL Client/Server Prot ...

  5. 0307-关于html

    html最主要的三点: 1.标签的写法.用法 <标签名 属性名1="属性值1" 属性名2="属性值2">内容</标签名> 比如:< ...

  6. Lintcode388 Permutation Sequence solution 题解

    [题目描述] Given n and k, return the k-th permutation sequence. Notice:n will be between 1 and 9 inclusi ...

  7. discuz7.2 faq.php 注入漏洞分析

    写在前面的话:分析完整个漏洞,不得不感叹,发现漏洞的人真的好细心呀. 在分析整个漏洞之前,没看poc,然后就直接看faq.php 准备试试自己发现漏洞的能力,但是分析完一整个php,也是卡在 in() ...

  8. [Codeforces 919E]Congruence Equation

    Description 题库链接 求满足 \[n\cdot a^n\equiv b \pmod{p}\] 的 \(n\) 的个数, \(1\leq n\leq x\) , \(a,b,p,x\) 均已 ...

  9. [COGS 2524]__完全平方数

    Description 一个数如果是另一个整数的完全平方,那么我们就称这个数为完全平方数(Pefect Sqaure),也称平方数.小A认为所有的平方数都是很perfect的~ 于是他给了小B一个任务 ...

  10. UVALive - 3530:Martian Mining

    dp 可以发现,对于(i,j),要么把它运上去,那么把它运到左边,枚举一下即可 #include<cstdio> #include<cstdlib> #include<a ...