字串变换(洛谷P1032 BFS+Hash)

题目描述
这道题实际上就是给你一个字符串,然后给你一些变换规则,问最小需要多少步数可以到达最终的那个字符串;
这道题呢,实际上是不应该用STL的,因为毕竟2011年STL才解禁,于是写了一个hash来代替set,目的是使一个子串不重复进队(但考虑到队列不好实现,便没有手写队列)
直接上代码:

#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int mod1=16927;
const int mod2=998244353;
queue <string> q;
queue <int> cnt;
const int N=6+5;
string a[N];
string b[N];
string s;
string t;
int n;

struct node
{
   
    int k1;
    string s;
    node(int kk1,string ss)
    {
   
        k1=kk1;
        s=ss;
    }
    node() {
   };
};
vector <node> v[mod1];

int get_hash_key(const string &letter,const int &mod)
{
   
    int ans=0;
    int len=letter.length();
    
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值