QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#722518#9571. Border Jump 2Kevin5307TL 1506ms174676kbC++203.7kb2024-11-07 19:21:492024-11-07 19:21:50

Judging History

你现在查看的是最新测评结果

  • [2024-11-07 19:21:50]
  • 评测
  • 测评结果:TL
  • 用时:1506ms
  • 内存:174676kb
  • [2024-11-07 19:21:49]
  • 提交

answer

#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define mid ((l+r)/2)
#define eb emplace_back
const int N=5e5+5,M=1e7+5,N1=1e3+5;
int T,n,f[N],g[N],w[N],f1[N1][N1];char a[N];
struct Point {int len,link,ch[26];};
int cnts;struct Seg {int ch[2];}sg[M];
int New() {sg[++cnts]=(Seg) {{0,0}};return cnts;}
int tot;
void upd(int &p,int l,int r,int x)
{
	tot++;
    if(!p) p=New();if(l==r) return;
    if(x<=mid) upd(sg[p].ch[0],l,mid,x);
    else upd(sg[p].ch[1],mid+1,r,x);
}
int merge(int pl,int pr)
{
	tot++;
    if(!pl || !pr) return pl+pr;
    int p=++cnts;
    sg[p].ch[0]=merge(sg[pl].ch[0],sg[pr].ch[0]);
    sg[p].ch[1]=merge(sg[pl].ch[1],sg[pr].ch[1]);
    return p;
}
bool qry(int p,int l,int r,int ql,int qr)
{
	tot++;
    if(!p || l>qr || r<ql || ql>qr) return 0;
    if(l>=ql && r<=qr) return 1;
    return qry(sg[p].ch[0],l,mid,ql,qr) || qry(sg[p].ch[1],mid+1,r,ql,qr);
}
struct SuffixAutoMaton
{
    int n,nw,cntp,o[N],d[N],rt[N],fa[20][N];
    bool vs[N];vector<int> e[N];Point pt[N];
    SuffixAutoMaton() {nw=cntp=1;}
    void clear()
    {
        n=0;
        for(int i=1;i<=cntp;++i)
        {
            pt[i].len=pt[i].link=o[i]=d[i]=rt[i]=vs[i]=0;
            fill(pt[i].ch,pt[i].ch+26,0);e[i].clear();
        }
        nw=cntp=1;
    }
    void ext(int w)
    {
        int p=nw,p1,t;pt[nw=++cntp].len=pt[p].len+1;
        o[++n]=nw;vs[nw]=1;
        while(p && !pt[p].ch[w]) pt[p].ch[w]=nw,p=pt[p].link;
        if(!p) {pt[nw].link=1;return;}p1=pt[p].ch[w];
        if(pt[p].len+1==pt[p1].len) {pt[nw].link=p1;return;}
        pt[t=++cntp]=pt[p1];pt[t].len=pt[p].len+1;
        while(p && pt[p].ch[w]==p1) pt[p].ch[w]=t,p=pt[p].link;
        pt[nw].link=pt[p1].link=t;
    }
    void dfs(int u,int f)
    {
        fa[0][u]=f;rt[u]=0;d[u]=d[f]+1;
        for(int i=1;i<=19;++i) fa[i][u]=fa[i-1][fa[i-1][u]];
        for(auto v:e[u]) dfs(v,u),rt[u]=merge(rt[u],rt[v]);
        if(vs[u]) upd(rt[u],1,n,pt[u].len);
    }
    int find(int u,int x)
    {
        for(int i=__lg(d[u]);i>=0;--i)
            if(pt[fa[i][u]].len>=x) u=fa[i][u];
        return u;
    }
    void build()
    {for(int i=2;i<=cntp;++i) e[pt[i].link].eb(i);dfs(1,0);}
    bool chk(int l,int r,int l1,int r1)
    {
		tot++;
        int t=find(o[r],r-l+1);
        return qry(rt[t],1,n,l1+r-l,r1);
    }
}SAM;
void slv()
{
    SAM.clear();cnts=0;
    scanf("%s",a+1);n=strlen(a+1);
    if(n<=30)
    {
        for(int i=n;i;--i) for(int j=i;j<=n;++j)
        {
            int t=i;
            while(t<j && a[t]==a[i+j-t]) ++t;
            f1[i][j]=max({f1[i+1][j],f1[i][j-1],(i<t?f1[i][t-1]+1:0)});
        }
        printf("%d\n",f1[1][n]);
        return;
    }
    for(int i=1,t=0;i<=n;++i)
        if(i==n || a[i]!=a[i+1])
        {for(int j=i;j>t;--j) w[j]=i-t;t=i;}
    for(int i=1;i<=n;++i) SAM.ext(a[i]-'a');
    for(int i=n;i;--i) SAM.ext(a[i]-'a');
    SAM.build();
    for(int i=1;i<=n;++i) f[i]=n;
    int ans=0;
    for(int x=1;x<=19;++x)
    {
        for(int i=2;i<=n;++i) f[i]=max(f[i],f[i-1]);
        fill(g+1,g+n+1,0);
        for(int i=1,t=0;i<=n;++i)
        {
            t=max(t-2,0);if(i>f[i] || f[i]-i+x-1<ans) continue;
            while(t<f[i]-i && SAM.chk(i,i+t,n*2-f[i]+1,n*2-i)) ++t;
            if(t==f[i]-i)
            {
                int t1=min(w[(i+f[i])/2],f[i]-i+1);
                ans=max(ans,(f[i]-i+1-t1)/2+t1-1+x-1);
            }
            else g[i]=max(g[i],i+t-1);
        }
        copy(g+1,g+n+1,f+1);
        for(int i=1;i<=n;++i) if(i<=f[i]) ans=max(ans,x);
    }
    printf("%d\n",ans);
}
int main()
{
    scanf("%d",&T);
    while(T--) slv();
	std::cerr<<tot<<std::endl;
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 24248kb

input:

3
aaaa
abbaabba
xy

output:

3
4
0

result:

ok 3 number(s): "3 4 0"

Test #2:

score: 0
Accepted
time: 5ms
memory: 24436kb

input:

15
eeee
ooom
bbcb
yyaa
ssdn
wgww
hrhr
exer
hcch
qyyy
lppa
ocvo
orxr
lrjj
pztv

output:

3
2
1
1
1
1
1
1
2
2
1
1
1
1
0

result:

ok 15 numbers

Test #3:

score: 0
Accepted
time: 0ms
memory: 24360kb

input:

52
eeeee
oooom
bbbcb
yyyaa
sssdn
wwgww
hhrhr
eexer
hhcch
qqyyy
llppa
oocvo
oorxr
llrjj
ppztv
tnttt
vnvvn
hthhp
jzjzj
nrnrr
gqgqt
uruyu
cdchd
djdhh
ktkfy
piipp
zaaza
uffuq
bvvvb
hkkkk
pcccj
qccpq
wqqaq
appgg
cxxvg
ewfee
peupe
odfof
kdpkh
zotoz
yzkzz
irtrt
vxyxi
dlood
akrrk
nsbbb
rdjjc
bfexb
uxsex
ise...

output:

4
3
2
2
2
2
1
1
2
2
1
1
1
1
1
2
2
1
2
1
1
1
1
1
1
2
2
2
3
3
2
1
1
1
1
1
1
1
1
2
1
1
1
1
2
2
1
1
1
1
1
0

result:

ok 52 numbers

Test #4:

score: 0
Accepted
time: 0ms
memory: 24444kb

input:

203
eeeeee
ooooom
bbbbcb
yyyyaa
ssssdn
wwwgww
hhhrhr
eeexer
hhhcch
qqqyyy
lllppa
ooocvo
ooorxr
lllrjj
pppztv
ttnttt
vvnvvn
hhthhp
jjzjzj
nnrnrr
ggqgqt
uuruyu
ccdchd
ddjdhh
kktkfy
ppiipp
zzaaza
uuffuq
bbvvvb
hhkkkk
ppcccj
qqccpq
wwqqaq
aappgg
ccxxvg
eewfee
ppeupe
oodfof
kkdpkh
zzotoz
yyzkzz
iirtrt
vv...

output:

5
4
3
3
3
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
1
1
1
1
1
3
2
2
3
3
2
1
1
1
1
2
1
1
1
2
1
1
1
1
2
2
1
1
1
1
1
1
3
3
2
3
2
2
1
1
1
1
2
2
2
2
2
1
1
1
1
1
1
2
1
1
1
1
1
1
2
1
2
1
1
1
1
1
1
2
2
2
2
2
2
2
2
2
2
3
3
3
4
4
3
2
2
2
2
1
1
1
1
1
2
1
1
1
2
2
1
1
1
1
1
1
2
1
2
1
1
1
1
1
1
2
1
1
1
1
1
1
1
2
2
2
2
1
2
2
...

result:

ok 203 numbers

Test #5:

score: 0
Accepted
time: 0ms
memory: 24300kb

input:

877
eeeeeee
oooooom
bbbbbcb
yyyyyaa
sssssdn
wwwwgww
hhhhrhr
eeeexer
hhhhcch
qqqqyyy
llllppa
oooocvo
oooorxr
llllrjj
ppppztv
tttnttt
vvvnvvn
hhhthhp
jjjzjzj
nnnrnrr
gggqgqt
uuuruyu
cccdchd
dddjdhh
kkktkfy
pppiipp
zzzaaza
uuuffuq
bbbvvvb
hhhkkkk
pppcccj
qqqccpq
wwwqqaq
aaappgg
cccxxvg
eeewfee
pppeupe
...

output:

6
5
4
4
4
3
3
3
3
3
3
3
3
3
3
3
2
2
2
2
2
2
2
2
2
3
2
2
3
3
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
3
3
2
3
2
2
2
2
2
2
3
2
2
2
2
1
1
1
1
1
2
2
1
1
1
1
1
1
2
1
2
1
1
1
1
1
1
3
3
3
2
2
2
2
2
2
2
4
3
3
4
4
3
2
2
2
2
2
1
1
1
1
2
1
1
1
2
2
1
1
1
1
1
1
2
2
2
2
1
1
1
1
1
2
1
1
1
1
1
1
1
3
2
2
2
1
2
2
...

result:

ok 877 numbers

Test #6:

score: 0
Accepted
time: 7ms
memory: 24368kb

input:

4140
eeeeeeee
ooooooom
bbbbbbcb
yyyyyyaa
ssssssdn
wwwwwgww
hhhhhrhr
eeeeexer
hhhhhcch
qqqqqyyy
lllllppa
ooooocvo
ooooorxr
lllllrjj
pppppztv
ttttnttt
vvvvnvvn
hhhhthhp
jjjjzjzj
nnnnrnrr
ggggqgqt
uuuuruyu
ccccdchd
ddddjdhh
kkkktkfy
ppppiipp
zzzzaaza
uuuuffuq
bbbbvvvb
hhhhkkkk
ppppcccj
qqqqccpq
wwwwqqa...

output:

7
6
5
5
5
4
4
4
4
4
4
4
4
4
4
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
2
2
2
2
2
2
3
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
4
3
3
2
2
2
2
2
2
2
4
3
3
4
4
3
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
3
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
3
2
2
2
2
2
2
...

result:

ok 4140 numbers

Test #7:

score: 0
Accepted
time: 3ms
memory: 24368kb

input:

21147
eeeeeeeee
oooooooom
bbbbbbbcb
yyyyyyyaa
sssssssdn
wwwwwwgww
hhhhhhrhr
eeeeeexer
hhhhhhcch
qqqqqqyyy
llllllppa
oooooocvo
oooooorxr
llllllrjj
ppppppztv
tttttnttt
vvvvvnvvn
hhhhhthhp
jjjjjzjzj
nnnnnrnrr
gggggqgqt
uuuuuruyu
cccccdchd
dddddjdhh
kkkkktkfy
pppppiipp
zzzzzaaza
uuuuuffuq
bbbbbvvvb
hhhh...

output:

8
7
6
6
6
5
5
5
5
5
5
5
5
5
5
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
4
3
3
3
3
3
3
3
3
3
4
3
3
4
4
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
...

result:

ok 21147 numbers

Test #8:

score: 0
Accepted
time: 90ms
memory: 103996kb

input:

2
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee...

output:

99999
99999

result:

ok 2 number(s): "99999 99999"

Test #9:

score: 0
Accepted
time: 575ms
memory: 174676kb

input:

2
eeegeeeggegegeeeegegeeeeegeeegeeeggeeeggegggegeggeeeeegegeeggeeeggggeggggegegeegggegggggeggggeegggegeeegggeegeeegeeeegeggegeggeggeggegggeeeeggeggggggeggegggeegegegggeggegggeegeeggegeegegggeegegegggegggeeeggeggeeegeeggeeggeggegggeggeegegegeeggggegggggegegggeeeegegeeggeggegggegegeggeegggeeeggeeggegg...

output:

21
19

result:

ok 2 number(s): "21 19"

Test #10:

score: 0
Accepted
time: 948ms
memory: 166904kb

input:

2
egooeoegeeggegeeoegggoeoegeeeoeegoeeeogeoggoggoegoegogooooggoeeeoogooegeooegeeggeeoegeogoggegoegoggogeoogegggogegogeoogoeeeogegeoeoggoogoeeooeeogeoegggggegoeoeeggogogggeggoegeogoeogggegggeoggggooggoeoeeoegoeeggoogggggegooggoeooeoeeooeooggogeogeeoogegegoggeogeooeoggeogegoeogeeogeegogegoogggogegogeg...

output:

12
12

result:

ok 2 number(s): "12 12"

Test #11:

score: 0
Accepted
time: 497ms
memory: 163816kb

input:

2
oeoaooeggegegoeeeaeaoeoeogoeoaoeoaaeooaaogagogeaaoeoooaogooaaooogaaaoaagaeaegoeaaaoggaaaogggaeoaaaegeeeggaeoaoooaoeoeaeggoaogaeggoggeggaeoeogaeaggagaoggoaageeaoaeggaoggoagaeoaeeagoaoogogageoaeaoaggogggoeoagogaoooaeeagoeaaeaaoggaegaoegoaoaeoagageagaagoaegaaoeoeaoaeogaeagoggaoaoaeaaeogggeeegaooagega...

output:

11
9

result:

ok 2 number(s): "11 9"

Test #12:

score: 0
Accepted
time: 436ms
memory: 157856kb

input:

2
ntiaoioraegexnnnnxtxeetoogetixnoegbeitbgnrxbiatabitooeatbiibbinnxrrataxaanxnaetxrroraggriraggoobbxegootgrgterottateonbtgxnxnrgoaanrgnbagetioagnbgrarbexatbggenrtbearrnbgtxaatirtnagoaoibigxxiibtxorxanarrtitrbobxnttroixrenxgobrnbarnaanoxignrengrxroababxtbnbxxeinerobtibbibrngrrerebtabetxgbnioggteaxtra...

output:

5
5

result:

ok 2 number(s): "5 5"

Test #13:

score: 0
Accepted
time: 380ms
memory: 153448kb

input:

2
ojzxseudqfxhvuomjrexifhnelffzyfiprrzforwfkwqedndbhmhnogfcfirkfumbqlbjxlldhlnbizrrlnvcqagfbbdcthlgyjlhujxyytzdzzidtsnfqikankokdickzgvjgyajjmhwxfyaaydlmylhcaasplhgslxgelkidgljigipgbfrfhkigkxefcsgulblhdvbjpovwocxifzwpnwqtpkbslqndgxnwvfjverfyneyqaleydxbkovfgvgminukorptglmlrjqlaubjyedlmtkqvtopvwmfaahrk...

output:

3
3

result:

ok 2 number(s): "3 3"

Test #14:

score: 0
Accepted
time: 2ms
memory: 24484kb

input:

100
eeegeeeggegegeeeegegeeeeegeeeg
eeeggeeeggegggegeggeeeeegegeeg
geeeggggeggggegegeegggegggggeg
gggeegggegeeegggeegeeegeeeegeg
gegeggeggeggegggeeeeggegggggge
ggegggeegegegggeggegggeegeegge
geegegggeegegegggegggeeeggegge
eegeeggeeggeggegggeggeegegegee
ggggegggggegegggeeeegegeeggegg
egggegegeggeeggge...

output:

7
5
6
5
6
6
4
6
6
4
6
10
7
5
10
6
10
8
5
10
7
10
7
6
11
10
8
7
5
5
7
8
5
6
6
10
5
7
8
8
8
6
7
6
9
6
6
6
4
5
5
4
6
8
8
6
6
6
4
9
11
7
5
12
8
8
9
7
5
6
10
6
6
7
7
9
5
7
11
6
8
8
5
5
10
6
9
6
9
8
5
5
6
6
6
8
6
7
9
6

result:

ok 100 numbers

Test #15:

score: 0
Accepted
time: 2ms
memory: 24356kb

input:

500
egooeoegeeggegeeoegggoeoegeeeo
eegoeeeogeoggoggoegoegogoooogg
oeeeoogooegeooegeeggeeoegeogog
gegoegoggogeoogegggogegogeoogo
eeeogegeoeoggoogoeeooeeogeoegg
gggegoeoeeggogogggeggoegeogoeo
gggegggeoggggooggoeoeeoegoeegg
oogggggegooggoeooeoeeooeooggog
eogeeoogegegoggeogeooeoggeogeg
oeogeeogeegogegoo...

output:

2
7
4
5
5
3
4
4
3
3
5
5
4
5
4
4
4
4
5
3
5
7
3
3
3
3
8
3
4
6
4
5
4
3
3
6
3
3
4
2
3
5
3
5
4
4
3
4
3
4
4
4
5
4
4
5
4
3
4
4
3
4
5
5
4
4
4
5
4
4
3
3
3
4
3
5
4
6
6
6
3
6
4
5
3
4
3
4
4
3
4
4
3
3
4
4
4
3
4
4
4
5
6
3
3
4
3
5
4
5
4
3
3
5
7
5
7
4
3
2
3
7
4
4
6
5
5
4
5
4
6
2
2
5
6
6
7
3
2
4
4
4
5
5
6
4
3
3
3
4
...

result:

ok 500 numbers

Test #16:

score: 0
Accepted
time: 1455ms
memory: 127736kb

input:

2
babbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbababbabbababba...

output:

37511
37511

result:

ok 2 number(s): "37511 37511"

Test #17:

score: 0
Accepted
time: 2ms
memory: 24304kb

input:

1
abacbaxyabcaba

output:

2

result:

ok 1 number(s): "2"

Test #18:

score: 0
Accepted
time: 1506ms
memory: 171896kb

input:

2
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

19102
17514

result:

ok 2 number(s): "19102 17514"

Test #19:

score: 0
Accepted
time: 628ms
memory: 165484kb

input:

2
ufgbkfjuuijotymncffyqnefotznsflvlihsxddzsjgkqvixsbtrbsbuooirmgytjbyfmlnqvnympwrrvkpacjouomhssrkcsdzbiijainkqfxyvleigspvnyweivxiaolxeatmaobcfczlicidyiozfhykxdvodanrcvlftjzxminuvvbmahwppjmxkmrfecmschtemfmedyduedbladcptkfjtovhcplarqdtcxhdlxpoqwmxfdveaksfvljgvimldtibzjccstyuwctjrptivddcphgmjjjeiuflqed...

output:

9999
9999

result:

ok 2 number(s): "9999 9999"

Test #20:

score: 0
Accepted
time: 512ms
memory: 158696kb

input:

2
eyqtmnrlcnohlapnzfpwmurpwngttugiqebhrvjsffsnribhchntexexcdlbwvtrdqyuajfrkegfixmewwqdhxpisibcnstuellgywtmngtaxhalgnjylglmdqxiaeqdhmalrvmljuqnrbuhwupcupsjdslnueybojeqhuxtfutscztokzwctikfalpkythkxyzxemizlewncihwjqhxxcxtuhnsebnenijhqrpjthyvqkqwkcqzgenfxeemsqlxnucfpzlbaemvhflhzgrpeckxfrrksbppiwsdghmbpl...

output:

4999
4999

result:

ok 2 number(s): "4999 4999"

Test #21:

score: 0
Accepted
time: 340ms
memory: 161880kb

input:

2
ivpnhczudisccdpuvnpthltbjnauoqjehspenapetoludiarsxftuwpzhvxofdzbmpzfdtuhavxcfdktfoceofowuhngrilioexzrydjrlbhzapcrhkbcbsjafaybzauyttajnsuiiaourefxcsrnafpvnidswelbanfhqtnffscraqfgnwmnbcarmkslrcmspvircgzjkztmztgmrqiopgbzxjhlrzrhqxrkyzclznfzqdqrzamvojicilyhyfqieoxygumfodmnyxkpzigpokngvqqtruhgzyngcuybf...

output:

5
5

result:

ok 2 number(s): "5 5"

Test #22:

score: 0
Accepted
time: 319ms
memory: 161220kb

input:

2
dcdyihlmsvlnewvitybmgqindedypovodrhvsomrhbtzokrvojunhvvegffukygrchxmzbuntugnunmloxiesdjbrqvfcitarlcdouhfktwpglyykuehlwxudcninuwzpaiahtbskewyozqwidlcprkrbpcdqqtluodfuttltpzxmmfcsihavyywecvugaojtvuqoadvsexnoohddzeyqbafvsxwfolxawigojpliretadebcgbwkrsjkzrqtzpdnsphmhdvreyslexnhhqkflumwnkhmfyufbpiokneiy...

output:

4
4

result:

ok 2 number(s): "4 4"

Test #23:

score: -100
Time Limit Exceeded

input:

2
hbbhbhhbbhhbhbbhbhhbhbbhhbbhbhhbbhhbhbbhhbbhbhhbhbbhbhhbbhhbhbbhbhhbhbbhhbbhbhhbhbbhbhhbbhhbhbbhhbbhbhhbbhhbhbbhbhhbhbbhhbbhbhhbbhhbhbbhhbbhbhhbhbbhbhhbbhhbhbbhhbbhbhhbbhhbhbbhbhhbhbbhhbbhbhhbhbbhbhhbbhhbhbbhbhhbhbbhhbbhbhhbbhhbhbbhhbbhbhhbhbbhbhhbbhhbhbbhbhhbhbbhhbbhbhhbhbbhbhhbbhhbhbbhhbbhbhhbbh...

output:


result: