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. Linux命令-权限

    Linux命令权限   1.新建用户natasha,uid为1000, gid为555, 备注信息为"master" 2.修改natasha用户的家目录为/Natasha 3.查看 ...

  2. Typescript学习

    一 什么是Typescript 简单的说,TypeScript 是 JavaScript 的一个超集,主要提供了类型系统和对 ES6 的支持,它由 Microsoft 开发,代码开源于 GitHub  ...

  3. FTP下载文件

    linux命令方式下载 step1: >>ftp ip port 根据提示输入用户名 根据提示输入用户密码 >>cd 目录(重要:一定要进入文件所在的目录) >>g ...

  4. vue 插值,v-once,v-text, v-html

    引入Vue.js ,通过script形式,vue官网语法记录 创建vue应用,数据和 DOM 已经被建立了关联,所有东西都是响应式的 1:插值 缺点:让你的网速慢,或者数据加载失败时,会在浏览器中直接 ...

  5. java---interrupt、interrupted和isInterrupted的区别

    1.interrupt()  interrupt方法用于中断线程.调用该方法的线程的状态为将被置为"中断"状态. 注意:线程中断仅仅是置线程的中断状态位,不会停止线程.需要用户自己 ...

  6. DDCTF 2018线上赛writeup

    第一题: d4e8e1f4a0f7e1f3a0e6e1f3f4a1a0d4e8e5a0e6ece1e7a0e9f3baa0c4c4c3d4c6fbb9b2b2e1e2b9b9b7b4e1b4b7e3e ...

  7. 机器学习基石:06 Theory of Generalization

    若H的断点为k,即k个数据点不能被H给shatter,那么k+1个数据点也不能被H给shatter,即k+1也是H的断点. 如果给定的样本数N是大于等于k的,易得mH(N)<2N,且随着N的增大 ...

  8. vim 多行缩进

    按v进入可视化模式后, 选中要缩进的多行, 后按shift+.实现多行缩进.

  9. [NOIp 2012]同余方程

    Description 求关于 x 的同余方程 ax ≡ 1 (mod b)的最小正整数解. Input 输入只有一行,包含两个正整数 a, b,用一个空格隔开. Output 输出只有一行,包含一个 ...

  10. [PA 2014]Lustra

    Description Byteasar公司专门外包生产带有镜子的衣柜.刚刚举行的招标会上,有n个工厂参加竞标.所有镜子都是长方形的,每个工厂能够制造的镜子都有其各自的最大.最小宽度和最大.最小高度. ...