NOIP模拟题 2016.10.4 [Hash] [dp] [复杂状态spfa]

这里写图片描述
这里写图片描述


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&
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值