T1:
一开始写的“康托展开”,然而发现这里并不能完美适用,因为很小的时候有重复,那么双hash就过了。
还有一种就直接排序后用set判断不同的个数。。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<string>
#include<iomanip>
#include<ctime>
#include<climits>
#include<cctype>
#include<algorithm>
#ifdef WIN32
#define AUTO "%I64d"
#else
#define AUTO "%lld"
#endif
using namespace std;
#define smax(x,tmp) x=max((x),(tmp))
#define smin(x,tmp) x=min((x),(tmp))
#define maxx(x1,x2,x3) max(max(x1,x2),x3)
#define minn(x1,x2,x3) min(min(x1,x2),x3)
const int INF=0x3f3f3f3f;
const int maxn = 10005;
const int maxl = 105;
const int SIGMA_SIZE = 30;
char s[maxl];
int n;
struct Hash
{
int hash1,hash2;
bool operator < (const Hash t) const
{
if(hash1^t.hash1) return hash2 < t.hash2;
return hash1 < t.hash1;
}
bool operator == (const Hash t) { return hash1==t.hash1 && hash2==t.hash2; }
}_hash[maxn];
unsigned int pool[SIGMA_SIZE];
int main()
{
freopen("word.in","r",stdin);
freopen("word.out","w",stdout);
scanf("%d",&n);
for(int i=1;i&