有一种2X2的牌,四个块上都有写数字,他不能翻只能旋转,90、180、270度,所以一种牌可以显示出共4种状态。
给一堆牌,问有几种。
把四个块标号为1234的话,那么一种牌就有1234、2413、4321、3142四种,用一个数组来存当前已经有的种类,然后每读入一个跟已有种类匹配,匹配完都没有找到一致的则设为新的一种。
#include <queue>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define gm(a,b,c,d) (a*1000+b*100+c*10+d)
#define out {flag=0;break;}
using namespace std;
int mrk[1000];
int main()
{
int n; cin>>n;
int ans=0;
memset(mrk,0,sizeof mrk);
for(int ni=0;ni<n;ni++)
{
int flag=1;
int n1,n2; cin>>n1>>n2;
int a=n1/10,b=n1%10;
int c=n2/10,d=n2%10;
string s; if(ni<n-1)cin>>s;
for(int i=0;i<ans;i++)
{
<span style="white-space:pre"> </span>if(gm(a,b,c,d)==mrk[i])out //1234
else if(gm(b,d,a,c)==mrk[i])out //2413
else if(gm(d,c,b,a)==mrk[i])out //4321
else if(gm(c,a,d,b)==mrk[i])out //3142
}
if(mrk[0]==0 || flag) mrk[ans++]=gm(a,b,c,d);
}
cout<<ans<<endl;
return 0;
}