D. Duff in Beach
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 a 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.
Case #x: y
, where x is the test case number (starting from 1) and y is either "POSSIBLE
" or "IMPOSSIBLE
" (quotes for clarity).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
题意
给你两个2*2的矩阵,判断一个旋转是否能得到另外一个
题解:
模拟不多说
///1085422276 #include<bits/stdc++.h> using namespace std ; typedef long long ll; #define mem(a) memset(a,0,sizeof(a)) #define meminf(a) memset(a,127,sizeof(a)) #define TS printf("111111\n") #define FOR(i,a,b) for( int i=a;i<=b;i++) #define FORJ(i,a,b) for(int i=a;i>=b;i--) #define READ(a,b,c) scanf("%d%d%d",&a,&b,&c) #define inf 100000 inline ll read() { ll x=0,f=1; char ch=getchar(); while(ch<‘0‘||ch>‘9‘) { if(ch==‘-‘)f=-1; ch=getchar(); } while(ch>=‘0‘&&ch<=‘9‘) { x=x*10+ch-‘0‘; ch=getchar(); } return x*f; } //**************************************** int main() { int oo=1; int a[6],b[5]; int T=read(); while(T--){ for(int i=1;i<=4;i++){ scanf("%d",&b[i]); } for(int i=1;i<=4;i++){ scanf("%d",&a[i]); } bool flag=0; if(b[1]==a[1]&&b[2]==a[2]&&b[3]==a[3]&&b[4]==a[4]){ flag=1; } if(a[3]==b[1]&&a[1]==b[2]&&a[2]==b[4]&&a[4]==b[3]){ flag=1; } if(a[4]==b[1]&&a[3]==b[2]&&a[1]==b[4]&&a[2]==b[3]){flag=1;} if(a[2]==b[1]&&a[4]==b[2]&&a[3]==b[4]&&a[1]==b[3]){flag=1;} printf("Case #%d: ",oo++); if(flag){ cout<<"POSSIBLE"<<endl; } else { cout<<"IMPOSSIBLE"<<endl; } } return 0; }
2015南阳CCPC A - Secrete Master Plan A.
原文:http://www.cnblogs.com/zxhl/p/4924227.html