当前位置: 首页 > 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.zqtcl.cn/news/494250/

相关文章:

  • 张家界做网站公司国内最先做弹幕的网站
  • 免费快速建站网站做网站用什么数据库
  • 哪有做课件赚钱的网站温州设计公司排名
  • 西安网站建设公司php大气企业网站
  • 天河公司网站建设内蒙古建设厅安全资料网站
  • 学习网站的建设怎么做网站建设作业
  • 做公司产品展示网站企业网盘源码
  • 南通做网站企业初中生代表性设计制作作品图片
  • php框架做网站好处网站后台模板免费下载
  • 新兴县建设局网站建筑工程网络计划技术
  • 住房和城乡建设部网站北京网站建设设计规划
  • 哪个网站做logo设计师网络营销心得体会800字
  • 广州一起做的网站动态数据库网站
  • 网站程序预装深圳市住房和建设局陈斌
  • 网站建设历程wordpress国内主题排行
  • 公司网站建设及优化计划书找能做网站的
  • 网站建设方案模板下载南宁有名的网络公司
  • 本地做织梦网站做软件怎么赚钱
  • a站全称重庆大学网络教育平台
  • 美橙做过网站案例好文案网站
  • 鞍山商城网站建设国外代理ip
  • 东莞网站设计风格wordpress不能启动怎么解决
  • 社交网站制作临海建设局网站导航
  • 合肥需要做网站的公司佛山网站制作的公司
  • 哪里有做网站平台建设网站如何盈利
  • dw网站制作素材单人做网站需要掌握哪些知识
  • 网络推广产品公司做移动网站优化首
  • 网站建设dqcx广告网络用语
  • 烟台网站建设首推企汇互联见效付款手机网站宽度自适应
  • 网站建设小程序湖南wordpress插件刷不出来