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

长沙优化网站服务360浏览器怎么加入可信站点

长沙优化网站服务,360浏览器怎么加入可信站点,手表网网站,郑州做网站九零后网络文章目录titlesolutioncodetitle solution 针对数据编程才是坠吊的#xff01;#xff01;#xff01; 观察数据#xff0c;发现分隔数据的LLL跨度过大#xff0c;没有衔接——推测很有可能是分数据做法 ①#xff1a;考虑L≤100L\le100L≤100的情况 可以暴力DPDPDP转移… 文章目录titlesolutioncodetitle solution 针对数据编程才是坠吊的 观察数据发现分隔数据的LLL跨度过大没有衔接——推测很有可能是分数据做法 ①考虑L≤100L\le100L≤100的情况 可以暴力DPDPDP转移 设dp[i][j]:dp[i][j]:dp[i][j]: 长度为iii指向自动机上jjj节点的方案数 枚举基本串kkk写个find()find()find()函数暴力找jjj节点跳基本串kkk后指向的节点tototo dp[ilen[k]][to](dp[ilen[k]][to]dp[i][j])%moddp[ilen[k]][to](dp[ilen[k]][to]dp[i][j])\%moddp[ilen[k]][to](dp[ilen[k]][to]dp[i][j])%mod O(L3)O(L^3)O(L3)完全可以非常可以很好很好 ②考虑基本串的长度只有1/21/21/2 思考一 此时LLL急速飙升一般上了1e7,1e8,1e91e7,1e8,1e91e7,1e8,1e9的数据点不是有规律周期可循就是n,logn\sqrt n,lognn​,logn 这里因为长度特别小加上之前的做题经验知道ACACAC自动机套矩阵快速幂的套路 于是自然而然就往矩阵加速方面靠了 思考二 对于长度为lenlenlen的一个串sss只有可能是由长度为s−1s-1s−1的一个固定的串s′ss′或者长度为s−2s-2s−2的一个固定的串s′′ss′′转移而来 如果借用上面的dpdpdp思路应该dp[len][to](dp[len−1][j]dp[len−2][k])%moddp[len][to](dp[len-1][j]dp[len-2][k])\%moddp[len][to](dp[len−1][j]dp[len−2][k])%mod 这个狮子不仅代表的是转移方程也在暗示每个状态只会与之前的最多两个状态挂钩 眼尖的犇犇更会发现有点像斐波拉契递推式——此时也会联想到矩阵加速求解 有长度为111的基本串也有长度为222的基本串矩阵要扩大两倍 也可以理解为把N×NN\times NN×N的一个矩阵看成一项fif_ifi​可以类比斐波拉契的转移推导过程 PS:下面的nnn仅代表一个字符含义并不是题目里的nnn 初始矩阵OOO (x0x1x2..xnx0′x1′..xn′)\begin{pmatrix} x_0\\ x_1\\ x_2\\ .\\ .\\ x_n\\ x_0\\ x_1\\ .\\ .\\ x_n \end{pmatrix}⎝⎜⎜⎜⎜⎜⎜⎜⎜⎜⎜⎜⎜⎜⎜⎜⎜⎛​x0​x1​x2​..xn​x0′​x1′​..xn′​​⎠⎟⎟⎟⎟⎟⎟⎟⎟⎟⎟⎟⎟⎟⎟⎟⎟⎞​ 我们想让ta转移成 (x0′x1′x2′..xn′x0′′x1′′..xn′′)\begin{pmatrix} x_0\\ x_1\\ x_2\\ .\\ .\\ x_n\\ x_0\\ x_1\\ .\\ .\\ x_n \end{pmatrix}⎝⎜⎜⎜⎜⎜⎜⎜⎜⎜⎜⎜⎜⎜⎜⎜⎜⎛​x0′​x1′​x2′​..xn′​x0′′​x1′′​..xn′′​​⎠⎟⎟⎟⎟⎟⎟⎟⎟⎟⎟⎟⎟⎟⎟⎟⎟⎞​ code #include queue #include cstdio #include cstring using namespace std; #define int long long #define mod 1000000007 int n, m, L, tot; char s[105]; int len[55]; int dp[105][105]; char S[55][105];queue int q;struct node {int trie[105][30], fail[105];bool End[105];void insert() {int now 0, Len strlen( s );for( int i 0;i Len;i ) {int nxt s[i] - a;if( ! trie[now][nxt] ) trie[now][nxt] tot;now trie[now][nxt];}End[now] 1;}void Fail() {memset( fail, 0, sizeof( fail ) );while( ! q.empty() ) q.pop();fail[0] 0;for( int i 0;i 26;i )if( trie[0][i] ) {fail[trie[0][i]] 0;q.push( trie[0][i] );}while( ! q.empty() ) {int now q.front(); q.pop();End[now] | End[fail[now]];for( int i 0;i 26;i ) {if( trie[now][i] ) {fail[trie[now][i]] trie[fail[now]][i];q.push( trie[now][i] );}elsetrie[now][i] trie[fail[now]][i];}}}int find( int now, int id ) {//求从now开始跳id串后指向的节点for( int i 0;i len[id];i ) {now trie[now][S[id][i] - a];if( End[now] ) return -1;}return now;/*这种写法是错误的从End[now]处理的是从根节点到now这一条串的路上是否含有一个被禁止的子串从被禁止的子串开始往下跳不算for( int i 0;i len[id];i ) {if( End[now] ) return -1;else now trie[now][S[id][i] - a];}if( End[now] ) return -1;else return now;*/}}AC;struct Matrix {int c[205][205];Matrix() {memset( c, 0, sizeof( c ) );}Matrix operator * ( const Matrix p ) const {Matrix ans;for( int i 0;i ( tot 1 | 1 );i )for( int k 0;k ( tot 1 | 1 );k )if( c[i][k] )for( int j 0;j ( tot 1 | 1 );j )ans.c[i][j] ( ans.c[i][j] c[i][k] * p.c[k][j] % mod ) % mod;return ans;}}O, V;Matrix qkpow( Matrix x, int y ) {Matrix ans;for( int i 0;i ( tot 1 | 1 );i )ans.c[i][i] 1;while( y ) {if( y 1 ) ans ans * x;x x * x;y 1;}return ans; } //dp[i][j]:长度为i指向自动机上j的方案数 void subtask1() {dp[0][0] 1;for( int i 0;i L;i ) { for( int j 0;j tot;j ) {if( ! dp[i][j] ) continue;for( int k 1;k n;k ) {int to AC.find( j, k ); if( ! ( ~ to ) || i len[k] L ) continue;else dp[i len[k]][to] ( dp[i len[k]][to] dp[i][j] ) % mod;}}}int ans 0;for( int i 0;i tot;i ) ans ( ans dp[L][i] ) % mod;printf( %lld\n, ans ); }void subtask2() {O.c[0][0] 1;for( int i 0;i tot;i )V.c[i tot 1][i] 1;for( int i 0;i tot;i ) {for( int j 1;j n;j ) {int to AC.find( i, j );if( ! ( ~ to ) ) continue;if( len[j] 1 ) {V.c[i tot 1][to tot 1] ;if( ! i ) O.c[0][to tot 1] ;}elseV.c[i][to tot 1] ;}}O O * qkpow( V, L );int ans 0;for( int i 0;i tot;i )ans ( ans O.c[0][i] ) % mod;printf( %lld\n, ans ); }signed main() {scanf( %lld %lld %lld, n, m, L );for( int i 1;i n;i )scanf( %s, S[i] ), len[i] strlen( S[i] );for( int i 1;i m;i ) {scanf( %s, s );AC.insert();}AC.Fail();if( L 100 ) subtask1();else subtask2();return 0; }
http://www.pierceye.com/news/775299/

相关文章:

  • 公司网站管理制定的作用网站建设设计文档模板
  • 做网站 附加信息全网整合营销公司
  • 做网站都需要用到什么软件每年网站备案抽查
  • 网站如何做电脑和手机软件ps素材网站大全
  • 佛山网站建设培训高能建站
  • 网站开发的相关技能广州有哪些广告公司
  • jsp网站设计用以前用过的域名做网站
  • 魔兽世界做宏网站家具设计与工程就业前景
  • 网站案例介绍平面设计网址推荐
  • 网站上的验证码怎么做简书 导入 wordpress
  • 想把公司的外部网站替换金戈枸橼酸西地那非片
  • 个人可以做社区网站淄博网站文章优化
  • 晋中建设集团网站windows图标wordpress
  • 如何创建商业网站为网站网站做代理被判缓刑
  • 个人备案做运营网站wordpress公众号源码
  • 营销网站服务器郑州金水区
  • 陕煤化建设集团铜川分公司网站大冶建设局网站
  • 网站如何制作django企业网站开发实例
  • 免费网站建设软件大全平面设计与网页设计
  • 建设网站 怀疑对方传销 网站制作 缓刑网站ip如何做跳转
  • 公司网站建设要求书网页怎么弄到桌面快捷方式
  • 做网站 公司 个体学校网站建设板块分析
  • 如何让百度更新网站收录wordpress图片处理类
  • 镜像网站能否做google排名企业做网站需要注意什么
  • 网站设计公司名称dz网站恢复数据库
  • 展示网站和营销网站的区别舆情分析师
  • 做网站用那一种语言最好网站推广指的是什么
  • 有哪些网站可以学做糕点的专业做网站建设公司怎么样
  • 广州网站排名怎么优化androidapp开发教程
  • 永顺网站建设网站建设免费建站