当前位置:网站首页>[learning notes] border and period

[learning notes] border and period

2022-07-28 10:09:00 Ants looking up at the starry sky

Actually, it's just copying blogs

Weak periodic theorem

1.1 1.1 1.1 if p p p and q q q yes s s s The cycle of , p + q ≤ ∣ s ∣ p+q\le |s| p+qs, be gcd ⁡ ( p , q ) \gcd(p,q) gcd(p,q) Also for the s s s The cycle of

prove :
Might as well set p < q p<q p<q, remember d = q − p d=q-p d=qp
because p + q ≤ ∣ s ∣ p+q\le |s| p+qs, about ∀ i ∈ [ 1 , ∣ s ∣ − d ] , i − p ≥ 1 ∨ i + q ≤ n \forall i\in [1,|s|-d],i-p\ge 1\lor i+q\le n i[1,sd],ip1i+qn
If the former holds , s i = s i − p = s i − p + q = s i + d s_i=s_{i-p}=s_{i-p+q}=s_{i+d} si=sip=sip+q=si+d
If the latter is established , s i = s i + q = s i + q − p = s i + d s_i=s_{i+q}=s_{i+q-p}=s_{i+d} si=si+q=si+qp=si+d
so d d d by s s s The cycle of
Obviously, you can finally get gcd ⁡ ( p , q ) \gcd(p,q) gcd(p,q) yes s s s The cycle of

border Structure

1.2 1.2 1.2 if 2 ∣ S ∣ ≥ ∣ T ∣ 2|S|\ge |T| 2∣ST, be S S S stay T T T The matching position in must be an arithmetic sequence .

prove :
First the T T T It's not being S S S Remove the covered part
Consider matching as greater than 2 2 2 The situation of
set up S S S stay T T T The first and second matching bit difference in is d d d, The bit difference between the second match and a later match is q q q, that d , q d,q d,q Are all S S S The cycle of , also d + q ≤ ∣ S ∣ d+q\le |S| d+qS, According to the weak periodic theorem r = gcd ⁡ ( d , q ) r=\gcd(d,q) r=gcd(d,q) yes S S S The cycle of , set up S S S The minimum period of is p p p, that p ∣ r p|r pr( Otherwise you can use WPL Construct smaller cycles ). here p ∣ r ∣ d p|r|d prd.
 Insert picture description here

if p < d p<d p<d, because p p p yes S S S The cycle of , Therefore, a matching bit closer to the first matching bit can be found , And d d d The definition of contradiction

 Insert picture description here
Therefore, it is only possible p = r = d p=r=d p=r=d, also d ∣ q d|q dq, So the matching bit is after processing T T T On , Every time d d d once , The matching position means that the tolerance is d d d The arithmetic sequence of .

1.3 1.3 1.3 character string s s s All not less than ∣ s ∣ 2 \frac{|s|}{2} 2s Of border \text{border} border Form an arithmetic sequence

set up s s s maximal border \text{border} border by n − p ( p ≤ ∣ s ∣ 2 ) n-p(p\le \frac{|s|}{2}) np(p2s), the other one border \text{border} border by n − q ( q ≤ ∣ s ∣ 2 ) n-q(q\le \frac{|s|}{2}) nq(q2s)
because p p p, q q q yes s s s The cycle of , therefore gcd ⁡ ( p , q ) \gcd(p,q) gcd(p,q) yes s s s The cycle of
therefore n − gcd ⁡ ( p , q ) n-\gcd(p,q) ngcd(p,q) yes s s s Of border \text{border} border
therefore p ∣ q p|q pq
Again because p p p yes s s s The cycle of , therefore s s s Your appearance can be painted
so s s s All not less than ∣ s ∣ 2 \frac{|s|}{2} 2s Of border \text{border} border Form an arithmetic sequence , The tolerance is p p p

1.4 1.4 1.4 inference : character string s s s All of the border \text{border} border It can be divided into O ( log ⁡ ∣ s ∣ ) O(\log |s|) O(logs) paragraph , Each segment is an arithmetic sequence

take s s s Of border \text{border} border on length x x x Divide into log ⁡ ∣ s ∣ \log|s| logs class , remember 2 k 2^k 2k Is no more than n n n Of 2 2 2 Power of power
x ∈ [ 1 , 2 ) , [ 2 , 4 ) , . . . , [ 2 k − 1 , 2 k ) , [ 2 k , n ) x\in [1,2),[2,4),...,[2^{k-1},2^k),[2^k,n) x[1,2),[2,4),...,[2k1,2k),[2k,n)
about x ∈ [ 2 k , n ) x\in [2^k,n) x[2k,n), obviously 2 k ≥ n 2 2^k\ge \frac{n}{2} 2k2n, Then this segment forms an arithmetic sequence
about x ∈ [ 2 i − 1 , 2 i ) x\in [2^{i-1},2^i) x[2i1,2i), Consider a clever structure
Let's go straight to the map You should understand 233
 Insert picture description here
The two tolerances are d1,d2 The tolerance should be lcm(d1,d2) Well

Then you can cut it off Mivik The title of the 了 .

原网站

版权声明
本文为[Ants looking up at the starry sky]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/209/202207280942133100.html