[CF1110H]Modest Substrings】的更多相关文章

传送门 如果\(r-l\)比较小,可以将所有满足条件的串扔进\(AC\)自动机然后在上面DP,从前往后确定字符串的每一位. 但是\(l,r \leq 10^{800}\)就十分不可行,所以需要优化这个算法. 考虑可能会有某一个节点的子节点连向的所有子节点构成一个满十叉树,意即当到达了这个节点之后可以随便往下走子节点,而且不论怎么走得到的结果都相同.比如说对于某一个九位数\(x = \overline {x_1x_2x_3x_4x_5x_6x_7x_8x_9}\),当前的\(l=123456789…
description CodeForces 定义一个正整数\(x\)是合适的当且仅当\(l\le x\le r\),其中\(l,r\le 10^{800}\). 找到一个长度为\(n\)的数字串,使其包含合适的数作为子串的次数最多,\(n\le 2000\). 如果有多解,输出字典序最小的那个. solution 如果模式串的个数不多,那么直接套用AC自动机上数位dp的方法即可. 关于这一方法可参见[SDOI2014]数数. 现在这个做法的缺陷是要放入的串太多. 考虑简化. 根据数位dp的思想…
题目简述:给定$1 \leq l \leq r \leq 10^{800}$,求一个长度为$n \leq 2000$的数字串$s$,其含有最多的[好]子串.一个串$s$是[好]的,如果将其看做数字时无前导零且满足$l \leq s \leq r$.形式化的说,就是求 $$ \arg \max_{s \in \Sigma^n} \sum_{i=1}^n \sum_{j=i}^n [s[i] \neq 0 \land l \leq s[i \dots j] \leq r] , $$ 其中$\Sigm…
CodeForces Global Round 1 CF新的比赛呢(虽然没啥区别)!这种报名的人多的比赛涨分是真的快.... 所以就写下题解吧. A. Parity 太简单了,随便模拟一下就完了. B. Tape 显然就是先找一个长的把所有的全部覆盖,然后可以在上面丢掉\(k-1\)段间隙. 那么把两两之间的间隙长度拿出来排序就可以了. C. Meaningless Operations 如果\(a\)不等于\(2^k-1\)的形式,那么令\(S=2^k-1\),其中\(2^{k-1}<a<2…
Consider the string s to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz", so s will look like this: "...zabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd....". Now we have another string p. Your job is to find…
Consider the string s to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz", so s will look like this: "...zabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd....". Now we have another string p. Your job is to find…
Description String analysis often arises in applications from biology and chemistry, such as the study of DNA and protein molecules. One interesting problem is to find how many substrings are repeated (at least twice) in a long string. In this proble…
Codeforces Round #258 (Div. 2) Count Good Substrings D. Count Good Substrings time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output We call a string good, if after merging all the consecutive eq…
题目 Source http://acm.hust.edu.cn/vjudge/problem/19225 Description The Hamming distance between two strings of the same length is defined as the number of positions at which the corresponding characters are different. For example, the Hamming distance…
Description Given a string, we need to find the total number of its distinct substrings. Input T- number of test cases. T<=20; Each test case consists of one string, whose length is <= 50000 Output For each test case output one number saying the num…