HDU-5540 Secrete Master Plan

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)
Total Submission(s): 801    Accepted Submission(s): 470

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 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, T(1≤T≤104). T test cases follow. Each test case contains 4 lines. Each line contains two integers ai0 and ai1 (1≤ai0,ai1≤100). The first two lines stands for the original plan, the 3rd and 4th line stands for the plan Fei opened.

Output

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

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

题意:

求所给矩阵能否经过旋转得到下一个矩阵。

就对比顺时针前后两元素是否相等即可。

附AC代码:

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3
 4 int main(){
 5     int t;
 6     cin>>t;
 7     int ans=1;
 8     while(t--){
 9         int a1,b1,c1,d1,a2,b2,c2,d2;
10         cin>>a1>>b1>>c1>>d1>>a2>>b2>>c2>>d2;
11         if(a2==a1&&b1==b2&&c1==c2){
12             cout<<"Case #"<<ans++<<": POSSIBLE"<<endl;
13             continue;
14         }
15         if(b2==a1&&a2==c1&&d2==b1){
16             cout<<"Case #"<<ans++<<": POSSIBLE"<<endl;
17             continue;
18         }
19         if(c2==a1&&d2==c1&&a2==b1){
20             cout<<"Case #"<<ans++<<": POSSIBLE"<<endl;
21             continue;
22         }
23         if(d2==a1&&c2==b1&&b2==c1){
24             cout<<"Case #"<<ans++<<": POSSIBLE"<<endl;
25             continue;
26         }
27         cout<<"Case #"<<ans++<<": IMPOSSIBLE"<<endl;
28     }
29     return 0;
30 }
时间: 2024-11-05 18:47:41

HDU-5540 Secrete Master Plan的相关文章

hdu 5540 Secrete Master Plan(水)

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

2015南阳CCPC A - Secrete Master Plan 水题

D. Duff in Beach Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 无 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, w

HDOJ5540 Secrete Master Plan

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5540 题目大意:给一个两个2*2的矩阵,第二个矩阵能不能通过旋转得到第一个矩阵 题目思路:模拟 1 #include <stdio.h> 2 #include <iostream> 3 using namespace std; 4 int ori[5][5]; 5 int par[5][5]; 6 int temp[5][5]; 7 void solve(int T){ 8 for(i

hdu 2251 Dungeon Master bfs

Dungeon Master Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 17555   Accepted: 6835 Description You are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may not be filled

HDU 5016 Mart Master II

Mart Master II Time Limit: 6000ms Memory Limit: 65536KB This problem will be judged on HDU. Original ID: 501664-bit integer IO format: %I64d      Java class name: Main Trader Dogy lives in city S, which consists of n districts. There are n - 1 bidire

hdu 1551 Cable master(二分)

Cable master Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 2003    Accepted Submission(s): 751 Problem Description Inhabitants of the Wonderland have decided to hold a regional programming co

HDU 5016 Mart Master II (树上点分治)

题目地址:HDU 5016 先两遍DFS预处理出每个点距最近的基站的距离与基站的编号. 然后找重心,求出每个点距重心的距离,然后根据dis[x]+dis[y] < d[y],用二分找出当前子树中不会被占领的数量,总点数减去即是被占领的数量.这样就可以求出每个点最多占领的点的数量.然后找最大值即可. 代码如下: #include <iostream> #include <string.h> #include <math.h> #include <queue&g

HDU 1551 Cable master【二分答案】

题意:给出n块木板,它们分别的高度,现在要把它们裁切成k块,问裁切成的最大的高度 二分答案,上限是这n块木板里面的最大值 然后每一个答案去判断一下是否满足能够裁切成k块 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include <cmath> 5 #include<stack> 6 #include<vector> 7 #include<map&

HDU - 6268: Master of Subgraph (分治+bitset优化背包)

题意:T组样例,给次给出一个N节点的点权树,以及M,问连通块的点权和sum的情况,输出sum=1到M,用0或者1表示. 思路:背包,N^2,由于是无向的连通块,所以可以用分治优化到NlgN. 然后背包可以用bitset优化.注意不要想着背包合并背包,背包只能合并单点. #include<bits/stdc++.h> #define pb push_back #define rep(i,a,b) for(int i=a;i<=b;i++) #define Gv G[u][i] #defin