题目链接:http://poj.org/problem?id=3349
题意:给出n个雪花,判断是否存在两个雪花相似。
这道题数据有点问题,不考虑同构就可以过
比如这组数据:
2
1 2 3 4 5 6
3 1 2 4 5 6
我也是后来看到discuss才发现的。另外还要考虑到顺时针的逆时针的问题,一片雪花应该有12中序列表示方式。
后来参考discuss的代码做了修改。
正确的代码:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
using namespace std;
const int INF=0x3f3f3f3f;
const int H=1200007;
const int maxn=1200010;
int n,cnt;
struct node{
int num[6];
int next;
};
node p[maxn];
int Hash[maxn];
void init(){
cnt=0;
memset(Hash,-1,sizeof(Hash));
}
bool cmp(int *a,int *b){
for(int i=0;i<6;i++){
if(a[i]!=b[i])
return false;
}
return true;
}
int getHash