首页 > 代码库 > HDU-5540 Secrete Master Plan
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): 470Problem DescriptionMaster 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.
InputThe 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.
OutputFor 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 Input41 23 41 23 41 23 43 14 21 23 43 24 11 23 44 32 1
Sample OutputCase #1: POSSIBLECase #2: POSSIBLECase #3: IMPOSSIBLECase #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 }
HDU-5540 Secrete Master Plan
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。