本題的意思和基本思維和容易~~按一定規則将每個雪花轉換成唯一的形狀~~然後比較就是了~~可以用Hash也可以排序後比較~~
為了使每個雪花按同一标準轉化成唯一~~我是最傻的辦法~~将每個雪花所有情況12種找出來~~找出序列最小的~~作為該雪花的關鍵順序~~這是最傻的也是最保險的.同時也是最好寫的...囧...
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
#include<cmath>
#include<queue>
#define oo 2000000000
#define ll long long
using namespace std;
struct node
{
int w[8];
}s[200000],temp[20];
int a[8];
bool f;
bool cmp(node a,node b)
{
int i;
for (i=1;i<=6;i++)
if (a.w[i]!=b.w[i]) return a.w[i]<b.w[i];
return true;
}
int main()
{
int m,x,y,i,k,n;
scanf("%d",&n);
for (m=1;m<=n;m++)
{
for (i=1;i<=6;i++) scanf("%d",&a[i]);
k=0;
for (i=1;i<=6;i++)
{
k++;
x=i;
for (y=1;y<=6;y++)
{
temp[k].w[y]=a[x];
x++;
if (x==7) x=1;
}
k++;
x=i;
for (y=1;y<=6;y++)
{
temp[k].w[y]=a[x];
x--;
if (x==0) x=6;
}
}
sort(temp+1,temp+1+k,cmp);
for (i=1;i<=6;i++)
s[m].w[i]=temp[1].w[i];
}
sort(s+1,s+1+n,cmp);
f=false;
for (i=1;i<n;i++)
{
for (x=1;x<=6;x++)
if (s[i].w[x]!=s[i+1].w[x]) goto A;
f=true;
break;
A: ;
}
if (f) printf("Twin snowflakes found.\n"); else
printf("No two snowflakes are alike.\n");
return 0;
}