Codeforces Beta Round #93 B. Password

该博客讨论了一道远古老题,题目要求找到一个在给定字符串s中出现在开始、中间和结束位置的子字符串。博主利用KMP算法的next数组预处理,结合哈希桶记录子串长度,通过while循环找到了符合条件的最大子字符串。
摘要由CSDN通过智能技术生成

 远古老题kmp+hash 

题义: 要求找到一个在s原字符串开端,中间,结尾都出现过的子字符串(可能无解)。

思路: 利用kmp中ne数组的定义,结尾与开端相同的最大子字符串的长度,通过预处理出原字符串的ne数组,哈希桶记录2到n-1的的ne值,while循环ne[n],得到最大合法子字符串

#include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<bitset>
#include<cmath>
#include<array>
#include<atomic>
#include<sstream>
#include<stack>
#include<iomanip>
//#include<bits/stdc++.h>

//#define int ll
#define pb push_back
#define endl '\n'
#define x first
#define y second
#define Endl endl
#define pre(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,b,a) for(int i=b;i>=a;i--)
#define si(x) scanf("%d", &x);
#define sl(x) scanf("%ll
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值