Codeforces 204 E

题意:给\(n\)个串,求对于每一个串在至少\(k\)个串中出现的它的子串\(S_{l..r}\)有多少个。

思路:后缀自动机上\(dp\)。。。

我们首先构造出这\(n\)个串的后缀自动机,其中需要注意将某个串的构建完了后直接将\(lst\)指针赋为\(root\),那么就可以包含这些串的所有子串并且不会有问题。

然后我们就考虑如何来算出某一个子串在\(n\)个串中出现了多少次。

假设现在我们从\(S_i\)的开头走到第\(j\)位,走到了节点\(u\),那么

看从\(u\)开始,沿着\(link\)一直走到\(root\)的一堆节点\(v_1..v_k\),这些节点表示的最长后缀没有在\(S_i\)中出现过,那么它们现在就标记为在\(S_i\)中出现过了,然后这些节点代表了结尾为\(j\)的所有子串们(根据定义),所以没有漏掉任何一个子串。

下面就是要求每一个节点对\(S_i\)的贡献了。对于节点\(u\),它对任何一个串的贡献就是它的\(link\)的贡献加上如果它出现大于等于\(k\)次,那么就再加上这个节点表示的子串数量:\(len_u-len_{link_u}\)(这个非常重要)。

那么顺着\(S_i\)跑到的每个节点\(u\)统计下答案就可以辣

【Codeforces 204E】Little Elephant and Strings的更多相关文章

  1. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  2. 【24.34%】【codeforces 560D】Equivalent Strings

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  3. 【codeforces 798B】Mike and strings

    [题目链接]:http://codeforces.com/contest/798/problem/B [题意] 给你n个字符串; 每次操作,你可以把字符串的每个元素整体左移(最左边那个字符跑到最后面去 ...

  4. 【52.49%】【codeforces 556A】Case of the Zeros and Ones

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  5. 【19.46%】【codeforces 551B】ZgukistringZ

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  6. 【codeforces 755B】PolandBall and Game

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  7. 【codeforces 750E】New Year and Old Subsequence

    time limit per test3 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  8. 【codeforces 761C】Dasha and Password(动态规划做法)

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  9. 【codeforces 761C】Dasha and Password(贪心+枚举做法)

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

随机推荐

  1. 【Mybatis】一对多实例

    ①创建数据库和表,数据库为mytest,表为teacher和student DROP TABLE IF EXISTS teacher; DROP TABLE IF EXISTS student; CR ...

  2. HDU6205

    card card card Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)To ...

  3. [VUE ERROR] Error in render: "TypeError: Cannot create property 'header' on boolean 'true'"

    项目基于ElemnetUi进行的开发,在引入第三方扩展库 vue-element-extends 之后使用它的表格组件报了这个错 解决方案: 1.  删除项目中的 node_modules 2. 删除 ...

  4. JavaScript按IP地址排序

    JavaScript按IP地址列表排序,主要思路就是分割每个点号部分,然后ip1和ip2分别对不够三位数的进行补0操作,然后转换为数字类型进行一一比较. 上代码: 正序: var arr=[ {ip: ...

  5. Expo大作战(三十六)--expo sdk api之 ImagePicker,ImageManipulator,Camera

    简要:本系列文章讲会对expo进行全面的介绍,本人从2017年6月份接触expo以来,对expo的研究断断续续,一路走来将近10个月,废话不多说,接下来你看到内容,讲全部来与官网 我猜去全部机翻+个人 ...

  6. CSS页面布局常见问题总结

    在前端开发中经常会碰到各种类型布局的网页,这要求我们对css网页布局非常熟悉.其中水平垂直居中布局,多列布局等经常会被使用到,今天就来解决一下css布局方面的问题. 水平垂直居中的几种方法 说到水平垂 ...

  7. c#事务处理(sqlTransaction)

    事务: /// <summary> /// 删除考勤 /// </summary> /// <param name="dto">Id</p ...

  8. 【HANA系列】SAP HANA XS使用Data Services查询CDS实体【一】

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[HANA系列]SAP HANA XS使用Dat ...

  9. 第五章 绘图基础(SINEWAVE)

    //SINEWAVE.C -- Sine Wave Using Polyline (c) Charles Petzold, 1998 #include <Windows.h> #inclu ...

  10. VM虚拟机打不开,没有反应,解决方法。

    最近的项目开发,需要用到虚拟机,但是打开虚拟机VM8却发现,以前创建的虚拟机都用不了,点击左侧[我的计算机]中的虚拟机列表,没有任何反应,也没有任何错误提示,服务中所有的虚拟机服务都开启了,网上百度没 ...