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. 基于Verilog HDL的超前进位全加器设计

    通常我们所使用的加法器一般是串行进位,将从输入的ci逐位进位地传递到最高位的进位输出co,由于电路是有延迟的,这样的长途旅行是需要时间的,所以为了加快加法器的运算,引入了超前进位全加器. 全加器的两个 ...

  2. python三元操作符

    #比较大小更简单了 x,y=3987,24361 small=(x if x<y else y) print(small)   #方法一:比较三个数的大小找出较大的一个 x,y,z=8,1,13 ...

  3. 类相关的BIF

    1.>>> issubclass(C,A)#判断c是A的子类,返回真假 2.>>> isinstance(b1,B) #判断c1是B类的实例化对象,返回真假 3.& ...

  4. [LeetCode] Find the Closest Palindrome 寻找最近的回文串

    Given an integer n, find the closest integer (not including itself), which is a palindrome. The 'clo ...

  5. [LeetCode] Find Bottom Left Tree Value 寻找最左下树结点的值

    Given a binary tree, find the leftmost value in the last row of the tree. Example 1: Input: 2 / \ 1 ...

  6. Python网络爬虫笔记(五):下载、分析京东P20销售数据

    (一)  分析网页 下载下面这个链接的销售数据 https://item.jd.com/6733026.html#comment 1.      翻页的时候,谷歌F12的Network页签可以看到下面 ...

  7. Mysql之表的操作与索引操作

    表的操作: 1.表的创建: create table if not exists table_name(字段定义); 例子: create table if not exists user(id in ...

  8. [ZJOI2008]泡泡堂

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

  9. [HNOI2008]遥远的行星

    题目描述 直线上N颗行星,X=i处有行星i,行星J受到行星I的作用力,当且仅当i<=AJ.此时J受到作用力的大小为 Fi->j=Mi*Mj/(j-i) 其中A为很小的常量,故直观上说每颗行 ...

  10. [HAOI2011]Problem c

    题目描述 给n个人安排座位,先给每个人一个1~n的编号,设第i个人的编号为ai(不同人的编号可以相同),接着从第一个人开始,大家依次入座,第i个人来 了以后尝试坐到ai,如果ai被占据了,就尝试ai+ ...