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

高碑店网站网站建设手机软件开发的模式

高碑店网站网站建设,手机软件开发的模式,内蒙建设厅网站,黑龙江网站开发传送门 文章目录题意#xff1a;思路#xff1a;题意#xff1a; 思路#xff1a; 由kmpkmpkmp中失配数组nenene的含义我们知道#xff0c;ne[i],ne[ne[i]],...ne[i],ne[ne[i]],...ne[i],ne[ne[i]],...都是iii的相等的前后缀#xff0c;但是可能有重叠的部分#xff0c…传送门 文章目录题意思路题意 思路 由kmpkmpkmp中失配数组nenene的含义我们知道ne[i],ne[ne[i]],...ne[i],ne[ne[i]],...ne[i],ne[ne[i]],...都是iii的相等的前后缀但是可能有重叠的部分那么就有一个显然的做法对于每个iii不断向前跳记录ne[x]i/2ne[x]i/2ne[x]i/2的个数复杂度O(n2)O(n^2)O(n2)。 考虑优化我们记录一个数组cnt[i]cnt[i]cnt[i]表示可重叠的后缀个数这个显然可以通过求nenene的时候递推出来那么我们跳到ne[x]i/2ne[x]i/2ne[x]i/2的时候直接加上cnt[x]cnt[x]cnt[x]即可但是这样还是会被aaaaaaaaaaaaaaa这种的串串卡掉继续优化。 考虑利用之前的信息由于到了iii我们就暴跳到ne[x]i/2ne[x]i/2ne[x]i/2那么对于i1i1i1一定有ne[x](i1)/2ne[x](i1)/2ne[x](i1)/2满足要求复杂度O(n)O(n)O(n)。 当然还有一个无脑的做法就是倍增优化暴跳的方式复杂度O(tnlogn)O(tnlogn)O(tnlogn)能过也是奇迹不过还是需要一些卡常的比如将数组f[N][20]f[N][20]f[N][20]写成f[20][N]f[20][N]f[20][N]这样快了1s1s1s。 O(n)O(n)O(n) // Problem: P2375 [NOI2014] 动物园 // Contest: Luogu // URL: https://www.luogu.com.cn/problem/P2375 // Memory Limit: 512 MB // Time Limit: 1000 ms // // Powered by CP Editor (https://cpeditor.org)//#pragma GCC optimize(Ofast,no-stack-protector,unroll-loops,fast-math) //#pragma GCC target(sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tunenative) //#pragma GCC optimize(2) #includecstdio #includeiostream #includestring #includecstring #includemap #includecmath #includecctype #includevector #includeset #includequeue #includealgorithm #includesstream #includectime #includecstdlib #includerandom #includecassert #define X first #define Y second #define L (u1) #define R (u1|1) #define pb push_back #define mk make_pair #define Mid ((tr[u].ltr[u].r)1) #define Len(u) (tr[u].r-tr[u].l1) #define random(a,b) ((a)rand()%((b)-(a)1)) #define db puts(---) using namespace std;//void rd_cre() { freopen(d://dp//data.txt,w,stdout); srand(time(NULL)); } //void rd_ac() { freopen(d://dp//data.txt,r,stdin); freopen(d://dp//AC.txt,w,stdout); } //void rd_wa() { freopen(d://dp//data.txt,r,stdin); freopen(d://dp//WA.txt,w,stdout); }typedef long long LL; typedef unsigned long long ULL; typedef pairint,int PII;const int N1000010,mod1e97,INF0x3f3f3f3f; const double eps1e-6;int n; char s[N]; int ne[N],pre[N];inline int read(){char chgetchar(); int x0,w1;while(ch0||ch9) {if(ch-) w-1; chgetchar();}while(ch0ch9) {x(x3)(x1)(ch^48); chgetchar();}return x*w; }int main() { // ios::sync_with_stdio(false); // cin.tie(0);int _; _read();while(_--) {scanf(%s,s1);nstrlen(s1);pre[1]1;for(int i2;in;i) {int jne[i-1];while(js[i]!s[j1]) jne[j];if(s[i]s[j1]) j;ne[i]j; pre[i]pre[j]1;}LL ans1;for(int i2,j0;in;i) {while(js[i]!s[j1]) jne[j];if(s[i]s[j1]) j;while(ji/2) jne[j];ans*pre[j]1; ans%mod;}printf(%lld\n,ans);}return 0; } /* abababab */ O(tnlogn)O(tnlogn)O(tnlogn) // Problem: P2375 [NOI2014] 动物园 // Contest: Luogu // URL: https://www.luogu.com.cn/problem/P2375 // Memory Limit: 512 MB // Time Limit: 1000 ms // // Powered by CP Editor (https://cpeditor.org)//#pragma GCC optimize(Ofast,no-stack-protector,unroll-loops,fast-math) //#pragma GCC target(sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tunenative) //#pragma GCC optimize(2) #includecstdio #includeiostream #includestring #includecstring #includemap #includecmath #includecctype #includevector #includeset #includequeue #includealgorithm #includesstream #includectime #includecstdlib #includerandom #includecassert #define X first #define Y second #define L (u1) #define R (u1|1) #define pb push_back #define mk make_pair #define Mid ((tr[u].ltr[u].r)1) #define Len(u) (tr[u].r-tr[u].l1) #define random(a,b) ((a)rand()%((b)-(a)1)) #define db puts(---) using namespace std;//void rd_cre() { freopen(d://dp//data.txt,w,stdout); srand(time(NULL)); } //void rd_ac() { freopen(d://dp//data.txt,r,stdin); freopen(d://dp//AC.txt,w,stdout); } //void rd_wa() { freopen(d://dp//data.txt,r,stdin); freopen(d://dp//WA.txt,w,stdout); }typedef long long LL; typedef unsigned long long ULL; typedef pairint,int PII;const int N1000010,mod1e97,INF0x3f3f3f3f; const double eps1e-6;int n; char s[N]; int ne[N]; int f[21][N];int main() { // ios::sync_with_stdio(false); // cin.tie(0);int _; scanf(%d,_);while(_--) {scanf(%s,s1);nstrlen(s1);for(int i2,j0;in;i) {while(js[i]!s[j1]) jne[j];if(s[i]s[j1]) j;ne[i]j; f[0][i]ne[i];}for(int k1;k19;k) for(int i1;in;i) f[k][i]f[k-1][f[k-1][i]];int ans1;for(int i2;in;i) {int now0,xi;for(int j19;j0;j--) if(f[j][x]*2i) xf[j][x];for(int j19;j0;j--) if(f[j][x]) now1j,xf[j][x];ans1ll*ans*(now1)%mod;}printf(%d\n,ans);}return 0; } /**/
http://www.pierceye.com/news/494250/

相关文章:

  • 公司网站开发国内外现状网络营销外包团队哪些好
  • 淘客网站怎么建立如何用api做网站
  • 合肥网站建设ahyedawordpress主题安全
  • 网站建设实训室介绍东莞seo广告宣传
  • 公职人员可以做公益网站吗aws网站建设
  • 什么叫高端网站定制广州建筑公司
  • 全新网站如何做百度竞价网站制作现状解决方案
  • 阿里云esc建设网站近三天时政热点
  • 怎样做公司网站介绍仿站网站源码下载
  • 电子商务网站规划与建设摘要软件app定制开发
  • 天水做网站的公司kj6699的seo综合查询
  • 找工程项目信息网站早那么做商城网站
  • 做网站优化销售管理系统排名
  • wordpress导入网站模板wordpress部分图片
  • 无锡做网站365caiyi秘密直播
  • 无锡企业网站制作报价公司做网站需要哪些手续
  • 最好的营销型网站保险购买平台有哪些
  • 网站建设实训的目的网站开发的框架协议
  • 本地郑州网站建设搭建一个网站
  • 如何做网站竞品分析哪个网站可以接任务做兼职
  • 佛山网站关键词网站建设需求分析文档
  • 网站收录地址旅游网站建设的相关报价
  • seo月薪seo优化方法网站快速排名推广渠道
  • 企业网站设计理念如何seo网站
  • 河南移动商城网站建设怎么创建平台卖自己的产品
  • 网上做网站钱被骗了报案有用吗文章自定义wordpress
  • 网站设置成灰色市场监督管理局是什么单位
  • 北京国贸网站建设wordpress需要付费才能看某些页面
  • 郸城网站建设wordpress教程cms
  • 做本地网站赚钱吗?php网站制作过程中遇到的问题及解决办法