Given an integer nnn and two binary strings a1a2ana_1a_2cdots a_na1a2an and b1b2bnb_1b_2cdots b_nb1b2bn of length nnn. Define function: f(l,r)={1,if∑i=lrai>rl+120,otherwisef(l,r)=begin{cases} 1,& text{if};sumlimits_{i=l}^r a_i > frac{r-l+1}{2}. end{cases}f(l,r)=1,0,ifi=l∑rai>2rl+1otherwise We say an integer kkk is lucky, iff for each ii,i, f=bifbig=b_if=bi holds. For each integer kk,k, determine if it is lucky.
Given an integer nnn and two binary strings a1a2⋯ana_1a_2cdots a_na1a2⋯an (denoted by AAA) and b1b2⋯bnb_1b_2cdots b_nb1b2⋯bn (denoted by BBB) of length nnn. Define function: f(l,r)={1,if ∑i=lrai>r−l+120,otherwisef(l,r)=begin{cases} 1,& text{if};sumlimits_{i=l}^r a_i > frac{r-l+1}{2} \ 0,&text{otherwise} end{cases}f(l,r)=⎩⎨⎧1,0,ifi=l∑rai>2r−l+1otherwise We say an integer kkk is lucky, iff for each i (1≤i≤n)i,(1le i le n)i(1≤i≤n), f(max(i−k+1,1),i)=bifbig(max(i-k+1,1),i big)=b_if(max(i−k+1,1),i)=bi holds. For each integer k (1≤k≤n)k,(1le k le n)k(1≤k≤n), determine if it is lucky.