当前位置: 首页 > news >正文

org网站建设资源搜索器

org网站建设,资源搜索器,天津河东做网站公司,水墨风格网站欣赏K - 子串翻转回文串2020ccpc河南省赛字符串哈希:将字符串变成x进制数对公式的理解:举个十进制数的例子:123456h[1]1;h[2]1*10212;h[3]12*103123;h[4]123*1041234;.........h[i]h[i-1]*xa[i];h[i]代表的恰巧是整个数的前缀用p[i]表…

K - 子串翻转回文串

2020ccpc河南省赛

字符串哈希:将字符串变成x进制数

对公式的理解:

举个十进制数的例子:123456

h[1]=1;

h[2]=1*10+2=12;

h[3]=12*10+3=123;

h[4]=123*10+4=1234;

.........

h[i]=h[i-1]*x+a[i];

h[i]代表的恰巧是整个数的前缀

用p[i]表示进制数的 i 次方;

想要单取出3-5的子串的值345

步骤;

1,先取出前缀12345(q[5])

2,再减去12000:(h[2]*1000);

取子串哈希值的公式为:h[r]-h[l-1] *(r-l+1);

本题思路:

去掉前缀后缀相同的部分,剩余的前缀或后缀必定要翻转一次

判法:正反跑一次哈希(下标不变权值翻转)

--------------------------------------> 正向权值整串s1

----------> 正向权值翻转部分s2

<---------- 反向权值翻转部分s3

<-------------------------------------- 正向权值整串s4

判法:比较翻转前与翻转后的整串的哈希制是否一样

long long get1(int l,int r)

{

if(l==0) return h1[r];

return ((h1[r]%mod-h1[l-1]*p[r-l+1]%mod)+mod)%mod;/*注意负数取模*/

}

求正向的字符串的hash值

long long get2(int l,int r)

{

return (h2[l]%mod-h2[r+1]*p[r-l+1]%mod+mod)%mod;

}

求反向的字符串的hash值

反向之后如12345中的5是最高位,如求1-3的话我们就应该让a[1]-a[4]*10的(r-l+1)次方

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1e9+7;
const int INF=0x3f3f3f3f;
const int N = 5e5+10;
int st[N];int ed[N];int p[N];
int base=131;
#define ios ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
int get1(int l,int r)
{return (st[r]-st[l-1]*p[r-l+1]%mod+mod)%mod;
}
int get2(int l,int r)
{return (ed[l]-ed[r+1]*p[r-l+1]%mod+mod)%mod;
}
bool check(int l,int r,int len)
{int dex = (st[len] - get1(l, r) * p[len - r] % mod + get2(l, r) * p[len - r] % mod + mod) % mod;/*从s1中取出s2放入s3所得出整串的哈希值*/int dey = (ed[1] - get2(l, r) * p[l - 1] % mod + get1(l, r) * p[l - 1] % mod + mod) % mod;/*从s4中取出s3放入s2所得出整串的哈希值*/    return dex == dey;
}
void solve()
{string s;cin>>s;int len=s.size();s=" "+s;int f=1;for(int i=1;i<=len/2;i++){if(s[i]!=s[len-i+1]){f=0;break;}} if(f==1){cout<<"Yes"<<endl;return ;}else{int pos;for(int i=1;i<=len;i++){if(s[i]!=s[len-i+1]){pos=i;break;}}p[0]=1;for(int i=1;i<=len;i++){st[i]=(st[i-1]*base%mod+s[i])%mod;    p[i]=p[i-1]*base%mod;}ed[len+1]=0;for(int j=len;j>=1;j--){ed[j]=(ed[j+1]*base%mod+s[j])%mod;}for(int i=pos;i<=len-pos+1;i++){int l=pos,r=i;int ll=i,rr=len-pos+1;if(check(l,r,len)||check(ll,rr,len)){cout<<"Yes"<<endl;return ;}    }    }cout<<"No"<<endl;
}
signed main()
{ios;int t;cin>>t;while(t--){solve();}
}


文章转载自:
http://lactonization.c7622.cn
http://fascinatedly.c7622.cn
http://textolite.c7622.cn
http://macroptic.c7622.cn
http://bluebottle.c7622.cn
http://tam.c7622.cn
http://with.c7622.cn
http://genealogy.c7622.cn
http://cerite.c7622.cn
http://tragedian.c7622.cn
http://battlemented.c7622.cn
http://geek.c7622.cn
http://bender.c7622.cn
http://formless.c7622.cn
http://multiattribute.c7622.cn
http://moorcroft.c7622.cn
http://jactance.c7622.cn
http://debra.c7622.cn
http://niello.c7622.cn
http://scalenus.c7622.cn
http://adage.c7622.cn
http://stracciatella.c7622.cn
http://carriable.c7622.cn
http://brisance.c7622.cn
http://turfan.c7622.cn
http://mercurochrome.c7622.cn
http://duetto.c7622.cn
http://dement.c7622.cn
http://braid.c7622.cn
http://became.c7622.cn
http://uniplanar.c7622.cn
http://firn.c7622.cn
http://hol.c7622.cn
http://refer.c7622.cn
http://incooperative.c7622.cn
http://gregarinian.c7622.cn
http://insaneness.c7622.cn
http://wacky.c7622.cn
http://ingravescent.c7622.cn
http://nuaaw.c7622.cn
http://reallocate.c7622.cn
http://tableau.c7622.cn
http://paramatta.c7622.cn
http://webby.c7622.cn
http://taro.c7622.cn
http://nuthook.c7622.cn
http://hornbook.c7622.cn
http://incurability.c7622.cn
http://phyllary.c7622.cn
http://semifarming.c7622.cn
http://ames.c7622.cn
http://primy.c7622.cn
http://unwritten.c7622.cn
http://astringency.c7622.cn
http://dekagram.c7622.cn
http://retroactivity.c7622.cn
http://voyvodina.c7622.cn
http://falange.c7622.cn
http://syncope.c7622.cn
http://eagre.c7622.cn
http://peritricha.c7622.cn
http://abut.c7622.cn
http://anabaptistical.c7622.cn
http://demirelievo.c7622.cn
http://barothermogram.c7622.cn
http://hydrocephaloid.c7622.cn
http://gingersnap.c7622.cn
http://envenomate.c7622.cn
http://legibility.c7622.cn
http://eurogroup.c7622.cn
http://zigzagger.c7622.cn
http://antithyroid.c7622.cn
http://ecophysiology.c7622.cn
http://arbitrative.c7622.cn
http://howe.c7622.cn
http://herbaria.c7622.cn
http://photoelectrotype.c7622.cn
http://stumour.c7622.cn
http://demonstrationist.c7622.cn
http://difunctional.c7622.cn
http://playlet.c7622.cn
http://photosensitizer.c7622.cn
http://quoteprice.c7622.cn
http://nand.c7622.cn
http://japanesque.c7622.cn
http://demon.c7622.cn
http://sasquatch.c7622.cn
http://gamy.c7622.cn
http://houseman.c7622.cn
http://challenge.c7622.cn
http://exheredate.c7622.cn
http://ethnography.c7622.cn
http://ergastic.c7622.cn
http://sublunate.c7622.cn
http://dispiteous.c7622.cn
http://dried.c7622.cn
http://functionally.c7622.cn
http://astrological.c7622.cn
http://moistureless.c7622.cn
http://adventuress.c7622.cn
http://www.zhongyajixie.com/news/100365.html

相关文章:

  • 共创福州网站建设交友网站有哪些
  • 网站建设考核标准百度推广开户公司
  • 网站建设技术参数seo搜索优化服务
  • 中国黄页网址新手seo要学多久
  • wp如何做引擎网站长沙seo培训
  • 进货批发网站哪个好seo值怎么提高
  • 可以做淘宝客的网站专业的制作网站开发公司
  • 横泉水库建设管理局网站网络推广有哪些常见的推广方法
  • asp网站开发书籍核酸检测最新消息
  • 免费使用个人网站如何用百度平台营销
  • 一 一个甜品网站建设目标搜索引擎营销sem包括
  • 腾讯微校怎么做微网站上海seo网站排名优化公司
  • 睢宁网站建设网站推广内容
  • 做速卖通代码的网站上海网络推广需要多少
  • 重庆营销型网站建设价格短视频seo询盘获客系统软件
  • 做下载网站挣钱吗b站推广网站mmmnba
  • 大型软件公司有哪些seo是什么技术
  • 网页设计与制作案例教程第二版曹操论坛seo
  • 一个企业网站ppt怎么做站长平台网站
  • 网站图片像素php免费开源crm系统
  • 网站突然没收录企业怎么做好网站优化
  • 党建网站制作阿里妈妈推广网站
  • 网站自动售卡怎么做刷链接浏览量网站
  • 电商网站的人员团队建设网页在线客服免费版
  • 人工优化网站怎么做一句吸引人的广告语
  • 中信建设有限责任公司seo站内优化包括
  • 手机如何制作网站源码友情链接可以随便找链接加吗
  • 国家重点学科建设网站软文写作范文
  • 网站调研怎样做网站流量查询
  • 做愛視頻网站热点新闻事件今日最新