HDOJ5540 Secrete Master Plan

时间:2023-03-10 07:27:56
HDOJ5540 Secrete Master Plan

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5540

题目大意:给一个两个2*2的矩阵,第二个矩阵能不能通过旋转得到第一个矩阵

题目思路:模拟

 #include <stdio.h>
#include <iostream>
using namespace std;
int ori[][];
int par[][];
int temp[][];
void solve(int T){
for(int i=;i<=;i++) for(int j=;j<=;j++) scanf("%d",&ori[i][j]);
for(int i=;i<=;i++) for(int j=;j<=;j++) scanf("%d",&par[i][j]);
bool flag=false;
for(int u=;u<=;u++){
temp[][]=par[][];
temp[][]=par[][];
temp[][]=par[][];
temp[][]=par[][];
temp[][]=par[][];
bool tmp=true;
for(int x=;x<=;x++){
for(int y=;y<=;y++){
if(ori[x][y]!=temp[x][y]){
tmp=false;
break;
}
}
if(!tmp) break;
}
flag|=tmp;
if(flag) break;
for(int i=;i<=;i++) for(int j=;j<=;j++) par[i][j]=temp[i][j];
}
printf("Case #%d: ",T);
if(flag) printf("POSSIBLE\n");
else printf("IMPOSSIBLE\n");
return ;
}
int main(){
int T;
scanf("%d",&T);
for(int i=;i<=T;i++) solve(i);
}