QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#708458 | #3844. LCS Spanning Tree | urayaha_yahaura | AC ✓ | 811ms | 228220kb | C++14 | 2.7kb | 2024-11-03 22:35:53 | 2024-11-03 22:35:54 |
Judging History
answer
#include<iostream>
#include<string>
#include<algorithm>
#include<cctype>
#include<cstring>
using namespace std;
typedef long long ll;
struct Edge{
int u,v,d;
}e[4000005];
string s,t[2000005];
int len,n,id[4000005],cnt[4000005],oldrk[4000005],rk[4000005],sa[4000005],height[4000005];
int pos[4000005],fa[2000005],num;
ll ans;
bool cmp(Edge a,Edge b){
return a.d>b.d;
}
int fnd(int x){
if(fa[x]==x)
return x;
return fa[x]=fnd(fa[x]);
}
void get_sa(string &t){
static int s[4000005];
int m=128;
for(int i=1;i<=len;i++)
s[i]=t[i]=='#'?++m:t[i];
m+=5;
int i,p,k;
for(i=1;i<=len;i++)
cnt[rk[i]=s[i]]++;
for(i=1;i<=m;i++)
cnt[i]+=cnt[i-1];
for(i=len;i>=1;i--)
sa[cnt[rk[i]]--]=i;
for(int w=1;;w<<=1,m=p){
int cur=0;
for(i=len-w+1;i<=len;i++)
id[++cur]=i;
for(i=1;i<=len;i++)
if(sa[i]>w)
id[++cur]=sa[i]-w;
memset(cnt,0,sizeof(cnt));
for(i=1;i<=len;i++)
cnt[rk[i]]++;
for(i=1;i<=m;i++)
cnt[i]+=cnt[i-1];
for(i=len;i>=1;i--)
sa[cnt[rk[id[i]]]--]=id[i];
p=0;
memcpy(oldrk,rk,sizeof(oldrk));
for(i=1;i<=len;i++){
if(oldrk[sa[i]]==oldrk[sa[i-1]]&&oldrk[sa[i]+w]==oldrk[sa[i-1]+w])
rk[sa[i]]=p;
else
rk[sa[i]]=++p;
}
if(p==len)
break;
}
for(i=1,k=0;i<=len;++i){
if(rk[i]==0)
continue;
if(k)
--k;
while(s[i+k]==s[sa[rk[i]-1]+k])
++k;
height[rk[i]]=k;
}
}
inline int read(){
int x=0,f=1; char c=getchar();
while(c>'9'||c<'0'){if(c=='-') f=-1; c=getchar();}
while(c<='9'&&c>='0') x=x*10+c-'0',c=getchar();
return x*f;
}
int main(){
int i,j;
n=read();
for(i=1;i<=n;i++)
fa[i]=i;
for(i=1;i<=n;i++){
t[i]='#';
char c;
while(!isalpha(c=getchar()));
t[i]+=c;
while(isalpha(c=getchar()))
t[i]+=c;
for(j=int(s.length())+1;j<int(s.length())+int(t[i].length());j++)
pos[j]=i;
s+=t[i];
}
len=s.length()-1;
get_sa(s);
for(i=2;i<=len;i++){
int u=pos[sa[i]],v=pos[sa[i-1]];
if(u&&v&&u!=v)
e[++num]=(Edge){u,v,height[i]};
}
sort(e+1,e+num+1,cmp);
for(i=1;i<=num;i++){
int u=e[i].u,v=e[i].v,d=e[i].d;
u=fnd(u);v=fnd(v);
if(u==v)
continue;
ans+=d;
fa[u]=v;
}
printf("%lld\n",ans);
return 0;
}
//abababab
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 8ms
memory: 108272kb
input:
4 icpc macau regional contest
output:
4
result:
ok single line: '4'
Test #2:
score: 0
Accepted
time: 11ms
memory: 110304kb
input:
3 ababa babab aba
output:
7
result:
ok single line: '7'
Test #3:
score: 0
Accepted
time: 271ms
memory: 153184kb
input:
26 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
output:
0
result:
ok single line: '0'
Test #4:
score: 0
Accepted
time: 12ms
memory: 108840kb
input:
7 jia ran jin tian chi shen me
output:
9
result:
ok single line: '9'
Test #5:
score: 0
Accepted
time: 15ms
memory: 108336kb
input:
10 theysaynothinglastsforever weareonlyheretoday loveisnowornever bringmefaraway takemetoyourheart takemetoyoursoul givemeyourhandandholdme showmewhatloveis bemyguidingstar itiseasytakemetoyourheart
output:
55
result:
ok single line: '55'
Test #6:
score: 0
Accepted
time: 16ms
memory: 110932kb
input:
100 dblkekaekijliimalcaidjjfaghdmhifkiebieffbddjmflkhagajcfmkccjjadgiijdbdldgbbhgcfdcadbeiabkemiefdccmhdcfilhkfabmfdmigfgigdcibgaeicedfiidgecbhdamiaiefbmbgbjhklbhafmhckklbmmiemkcbfgjihmdjkai bciiecmbc cdjailkkbefkbmlekiefdhklcbdccfbgkagflfemjjmkjmcgiibldlmhbcldjajgafmakfbhecgcckkkglklljhmliehidbkicm...
output:
476
result:
ok single line: '476'
Test #7:
score: 0
Accepted
time: 271ms
memory: 176844kb
input:
2000 ecbhcebgbcjgjiihdefajfbbaajfjdedggciaegdiijhijgedbgejhgjjfhabdfhbihdeegcehbcjhgebcjachbdeiefejefhcjdihfcfgeegdahhjhjiiffjjadifiijjbhhjjeffabiaagcjhaachjbiecfeceefddecjchjfibgedfdghgdijdcdahfeddjihbhbbghjjffdcibaggiiadbaajhfcgdbaafbicahjhabfdbeacccfdehebciafaaffdfjdciafbhidbahdccjhjdadcciecfbhac...
output:
17765
result:
ok single line: '17765'
Test #8:
score: 0
Accepted
time: 248ms
memory: 183180kb
input:
1413 gjjmlceglbmbibjmmfcfmickcllfekgmicmifdbfgdgbeecgjgalbfkdfljjkclfgkaacdgigblaiaiehkeiccbjamikdgcjfemhhfebicddelklibjafmjhleebkimeblljfembgcgacdlkhjmbijjgacjaajebjfkcllffalheefeaedbmmkicaeecckdmedddbikeieimjmmcfdcgamicfbeimkjfamidjfhejdgiehkjkbdaaaeieldfibkkcgallieiamfehcdggiigkabblgigjgdlmflmafj...
output:
11429
result:
ok single line: '11429'
Test #9:
score: 0
Accepted
time: 176ms
memory: 228220kb
input:
2000000 j o v p h b t s x y u c t n p l b e c v d c p s u m d d i m h t a e j i i c c h d x j w m a j p f l n i q c c k q g q b u z u v d d f n i j v n i e l w h v m m i z w y d z l w h b x b a r y d x f r h p o u x u f u b c i p l j o j o n u k w x h z x z y d y d w h u k b u e i o g n y x y h l j ...
output:
1999974
result:
ok single line: '1999974'
Test #10:
score: 0
Accepted
time: 243ms
memory: 173076kb
input:
2 adwkgmoosmodblpylbpymmnbzyjzddfegdqppefjstpueeurhjpuvdxudgtgmaksfdjwhogcivwmbqeiavcxybubknkwqwqxzaujoclyzhnaztibonzpotsaicwaznyapujfwugvdtxfmhgcuhrlcklnminnxnoojzvfwbczubgijnldwcqzocodmdqltgzcguicwmdsombxbmcxotyfvmijsaulhtnppxtnkygakhzltbjjwjqrwyaozwzgroxhmquyocazjzkecvqzfgqdhttgpuojilqwbmurruscvd...
output:
8
result:
ok single line: '8'
Test #11:
score: 0
Accepted
time: 321ms
memory: 183548kb
input:
1413 ababaaaababbababbabbaababaabaaaabaabbabababbbabbaaababbbbabbababaaababbbaabbaaabaaabababbbbbbbabbaababbababaaabaabbaaaaabbbaaabbabaaabaabaababaaabbabbabaabaabbaabbbbbbabbabaaaabbababaabbababbbaaabababaabaababaaaabaaaaababbbbbbbbabbabaabbaabbbbabbbbbaaabbbbbaabbbaabababababaaabbaaaaabbaaaabaaaaa...
output:
42405
result:
ok single line: '42405'
Test #12:
score: 0
Accepted
time: 256ms
memory: 182564kb
input:
1413 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
output:
1995156
result:
ok single line: '1995156'
Test #13:
score: 0
Accepted
time: 228ms
memory: 163008kb
input:
1 baababbbbbaaabbaabbabaabbabaababaabaaabbbbbbbabbbababbbabaaababbbabbabaaabbbbbaabbaabbaabaaabaaaabbbabbbaaabbbbbabbbaaabaabbabbbbaabbbabbbababaaabaababaabbbababbabbbbaaabbaabbbbbbabbabaaaabaaaabbbaaabbbbbbaaabaaabbabbababbabaabbabababababbbbaaababaaaabaabaaababbbbbabbbaaaaaababbbbbababaabbbabaaaab...
output:
0
result:
ok single line: '0'
Test #14:
score: 0
Accepted
time: 539ms
memory: 186308kb
input:
1413 fnjfbnhskrerdxmxrlthhclkgcfrwukmccsfpbazsetxbfwvsseauqmcuutqofeshwxyxxasbtpfaocsgguayjcsdxitcnllliljglbjesqggubmbvozessjpcctrngdwsoedrpkjgsqatedrtfvlzhddjyvxfavxozcfooowhgzalctgjrriywmhvjeajzzxadepsslbbkdmpxsaoljmixvdgafpbgocjstdmegnrkbijvizjtnrqiwykdpmjfquxjympeziqdsbydahwpapyypkbfwmkohkxfwplv...
output:
464827
result:
ok single line: '464827'
Test #15:
score: 0
Accepted
time: 563ms
memory: 186488kb
input:
1413 vrotfwuoloxhchhuitgryunhjurviyookrumnoabeziigrdpmlglfvurrlmblapvtlkhbmkgmuosltjxerkkmfdfspgeqwbjhlslycrkwhehdohhhrtuwwbpmivegwppikaimtulbyugobnwvjsrhtivddzjcrbmbbupvoayoxefatdvexnmqxhwdjhfairbmlsjbvjrspwsibonydbrcinfrwkrfduropcrkljeahyijoxhryaujnzakmurpqkgfmxpxivzsuhbihkchnwsaxtmlpfbfphldgccrab...
output:
254582
result:
ok single line: '254582'
Test #16:
score: 0
Accepted
time: 514ms
memory: 185300kb
input:
1413 bbbbbabaabbabbbbbbaaabbaabaaabaabbabbaabaaabbbaaaaaabbaaabaaaabbabbbbbbbabbbbbabaaabaababbbaaabababbaaaaabbbbbabaaaabaaabbabbabbabaabaabaaabbbabbabaaababbbbbbaaaaababbabbbaabaaabaabbabbaaabaababaaabbbbabbabbabaaabbbabbbabbbbabaabbbabbbbabbbbaaabbbabaaabbaaaaabbababbababbbbbbaaaabaaaabaaaaabbabb...
output:
1498740
result:
ok single line: '1498740'
Test #17:
score: 0
Accepted
time: 490ms
memory: 186392kb
input:
1413 lcoqmejczgztniltuwtqgzmgyjdvkiqvlgozlzdmhchwksqerjuxkigjslgetycefqfqriezkmvwgndxyzvjiducocihbkogctyuecvqqqnxgsuerrpbwldkooupyixbdvxjzsaskppqhlvafmcbyfmmtgduqaxvxwfwohoawftfrofwahxyplmktpglrfjobolpxbsvhlaabhydrxeijqueibqzgzoipbzmctjlelnfsllllptufqaptqpzrdjgeluigdwlolsjzdwkusgcigrbzgcqlozpbvahzys...
output:
1285703
result:
ok single line: '1285703'
Test #18:
score: 0
Accepted
time: 607ms
memory: 188088kb
input:
500 eqrouzrzqavpwipjhbpbbsypakjkmpithzhdazdqzyivgzhpawsdorsrdcdstllansenrjgsjqqspxhrvaumtnfwrioktzmiusynbegluwdlvmcsoyghlleetuopwdzqxxdzdlmzjrkgdozunhbythfoetdaydswcxxgllfucsbhgcbtjduemztquysvdkrikqovbvpdnsmuwopitjmhkhyfiqaldtvnjjikhzpwubsqriymtnueuulcmnqrglepxobgqqcktvaldbzwovcirnneafvisczpsavisauo...
output:
93437
result:
ok single line: '93437'
Test #19:
score: 0
Accepted
time: 557ms
memory: 187416kb
input:
500 aababbabbbabbbaabbaaababaabbabbaaaabbaaababababbbbbbbaabaaaabaabaabaababaabbaaabaaabaaaaabaababbaabaaabaaabababbabaabaaabaaaabaaabaabbabbbbababbbbbbabbbbbabaababbabaaaaaaabaabababbaabbbbbbbaaaaababaababaabbaaabaabbbaaaabbabbabbbbaabbbbaaaaabaabbabbababbaaababaaabbbabbabaaaabbaabbababbbbabbabbbaa...
output:
621482
result:
ok single line: '621482'
Test #20:
score: 0
Accepted
time: 610ms
memory: 184228kb
input:
500 xkhhkzemvoilwwysloxrngtnalowphqotywezcsuqahpwhjjwjalpvysipqxyhoshkyioqchqlyothxrqacivacersdqbrkkdisuywdqibgdidwbfylbanhsfmkjgutlemfeiiusjaxuftvltgoutxoajajpwfbatiedtawcavwhptsizieufsxpuigqnjqguwknwirydqgujadlljfqeehynopazfhtetgabazgqhbzjgkupsltwusjijmkqtduomvpmwvcfydoeoluiypesjqbscnjxqdleacsyzwd...
output:
1305055
result:
ok single line: '1305055'
Test #21:
score: 0
Accepted
time: 553ms
memory: 183932kb
input:
500 afdppltdvwipholvfwehnlbcmcxujuxlbabqnwtiudzbunzzjfiwqjzclyzwswiuylmmjiwdlygflfhumrtcbuhosgnmexieivsrdpuopcwckdywwrzxliofqdswacaixtbckxtzzpbjubgqthqgrgmhjgdjidtiyukitdhuukeqmmhhvzpmfbvqjazsfuceqomjuwdoijhwvodqptewwzmgznafhejxsvimtldcvkasagjpbnnzpbhoohtxnewgceuvrxzojahjgsajhniwoqlezgbnlzvndpixpkly...
output:
1248710
result:
ok single line: '1248710'
Test #22:
score: 0
Accepted
time: 490ms
memory: 186652kb
input:
4000 gdlglqbydbkucqucvkhjoicbrutfyulgywmlpqlurxpvqhkywpnnwerqgjnnxyheruhcotfjpohhyrfwiulgbcyjnnwlofrfcykqspchfjqfcyemupuvutghifuykmeokohcfjlmueuycykwpeujzctkhpibmfvorjdmqztnqyqzjgzcsekanoxzescqxxeojjczivoywhzhpzjhftkvjhunzwfzwlphvsifpweldfstgdcoymjktfzvdfubqlilfqrvpxiuednlgqzhekrypstuxpwqagbgzubotli...
output:
587656
result:
ok single line: '587656'
Test #23:
score: 0
Accepted
time: 481ms
memory: 187572kb
input:
4000 baabaabbababbbbbabaabaabababaabaabbbabbaaaabbbabbaaababbbaaaabaababbbbbbbbaaaaabbabaabbabbabaabbaaabbbaaaabbbbaabaabbbbaabbaaaaaaaaaaaaabbbaaaabaabbbabbaabaabaaaaaabbaaaaabaaaaabbbaaaaabaabaaaaaaabbaabbaaabbaabaabbabbbaaaaaaabbbabbbabbaaabaababbaaabbaabbababaabbbbaaaaabbaabbbaaabbabababbbbbaaaa...
output:
867646
result:
ok single line: '867646'
Test #24:
score: 0
Accepted
time: 449ms
memory: 187584kb
input:
4000 baaaabbabbaaaabbbaaabbababaaaababbbaaabbbbbbbaabaabbbbbbbbbbbabbaabaabbbaabaabbaaaababbbaaabbbabaababaababbaaaaabaabbbabbababbbbbaaaaaaabbabababbaabbaaaabbbbababbbbbbaaaababbbbbbaababbaabbaabbbababbaabbabbaaababababaaababbbaaabbaababbbbbaaaabababaabbabaabaaaaabbaaaabbababaaaaaaababaabbbbabbbabb...
output:
870160
result:
ok single line: '870160'
Test #25:
score: 0
Accepted
time: 458ms
memory: 183792kb
input:
4000 jnbnjwgrxbxyqkbxyktdciatkisupcgkaanotwsywpwnczkakgfmohiypavecbrddgrwemuadsphrchdioswvaxnastcvmhasbwynsbsmqafsjjcybzvbwidqchnqpnjqjjfdkzpbzuvldyjgzejxpmntuajlpufrlzkaisoonwikhonlrvvrqszrenfgtmyeokhwcxkrwtbdjqqalltddvvhicqbroifyrbcootmjwrsmhuxspdykahscxwtnganxepnskabgrvuzrutgxttxdlbajvqpvdmbtatfc...
output:
913862
result:
ok single line: '913862'
Test #26:
score: 0
Accepted
time: 392ms
memory: 184236kb
input:
4000 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
output:
1979531
result:
ok single line: '1979531'
Test #27:
score: 0
Accepted
time: 457ms
memory: 184944kb
input:
4000 fdhdijdfcdeedcbjgafdgcdegdbibaahdhaeifbdafhfhaefacigedcdhfbifdhbcjhaeidhdccdchicbjafceabjdchgjaabhbffgcajhdbecghdiehffjgiddhcfhdcabhhfigcdjihffagaibhjhhcdegiecbedabaajdgjbefbdbadcdeefgbibbhgaedhbhjgejchfjiididfcibjefhfgebiagfdfejjgbhdcfefghdafgjbbijaeciebghgcgiijhedeijahecfabgcbhefacbbaijdghdhe...
output:
1228665
result:
ok single line: '1228665'
Test #28:
score: 0
Accepted
time: 443ms
memory: 182800kb
input:
4000 rjdknocpagvrnghrpyukwifkkddprokianvndxdwgczcauhwrkpqmhqsmxqpmoxhazmujpspurtwndsfphxcrnwfnmuzauictvwfmowghscvvwckgzoxnkcawybzukbohyvtmrcwjgrgdvzovoosphzmirifzwmbfzuauwkmgoaodbfasvtjcuxmnftmcfohhkhdgtppkrfnvmpnhiwletasztebbskidtnjocaywgnrsdecnapsvpkuloxojjymelxtpyrlgfcakiexkurglbcwscmblkpqvmjlmcw...
output:
911422
result:
ok single line: '911422'
Test #29:
score: 0
Accepted
time: 379ms
memory: 189036kb
input:
100000 tduxfndk uneyosepeblysz myyzqqfxlyol hueyo vxkovfhrybgmvlhweq jkcclhdeyo dyggb mokfduurtqfsmaeynq gluuajukjnjc dfcjqnme xyrupyxgfnwd hvdjjbewg jjeyjmmlyol fiqebs otpjpq nfmezyyuyme wxyiuymslehvl coshvqaht tftlwgbnjyicrvjmuwrx owpmmwkqpvhwxhiujh vxrvymrouzryawtwombk ukkzjbon gokkrpnzmhonmhkfpj...
output:
989636
result:
ok single line: '989636'
Test #30:
score: 0
Accepted
time: 368ms
memory: 191096kb
input:
100000 baaabbbbabbabaaaba baabbaababbababbb bbbbbaababab baaabbaa abbabbbb baaabba baaabbbbbab bababbabbbb aababbbbbaabbbbabbbb abaababbaaaaabbb abaaabaaabbbbabbb bababaababbb aababbabbbbbbababba abaabbabab abbabbaaabaaaabbaaba abbaaabbaabbbba bbaababbabbaaabaaaa aaababaaabbbabb babbbb bbbbaaaabaabb...
output:
1282986
result:
ok single line: '1282986'
Test #31:
score: 0
Accepted
time: 316ms
memory: 187052kb
input:
100000 pkhvbtnxfvxaem uxvbtnxcgcsmwurthw rfvxaem wgzfvxaem fafvxaem nghhlpjfdga wcljhoesadwmfwhvbtnx uvbtnx bcbffvxaemvbtnx jhoesadwmfwhvbtnx ncgcsmwurthwvbtnx kyvbtnxjhoesadwmfwh wavbtnxjhoesadwmfwh ivbtnxssu qnghhlpjfdgarjw vbtnxibjhoesadwmfwh zfvxaemigqvbtnx swcgcsmwurthwsc sjhoesadwmfwh dfvxaemp...
output:
1170625
result:
ok single line: '1170625'
Test #32:
score: 0
Accepted
time: 488ms
memory: 187332kb
input:
100000 aaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaa aaaaaaa aaaaa aaaaa aaaaaaaaa aaaaaaaaaaa aaaaaaaaaaaaaaaa aaaaaaaaaaa aaaaaaaaaa aaaaaaaaaaaaa aaaaaa aaaaaaaaaaaaaaaaa aaaaaaaaaaaaaa aaaaaaaa aaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaa aaaaaaaaaaa aaaaaaaaaaaaaa aaaaa aaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaaaaa ...
output:
1950179
result:
ok single line: '1950179'
Test #33:
score: 0
Accepted
time: 712ms
memory: 184720kb
input:
20 cqhcbnnuobmgcqfdzbuvyajaidogyrtcjbemouifxulzlqcmtwiryttiwhpuykxjldvaxefuastnkvaeukxsdtdcauwbevkqziswmzrmrmabkchemhyrabtavqdajwzphqhuggbrujigzfhqxcrtcifvvvfgrevavfwdlauhjenkjudgyubcfhxcccivjfyemujywfhfjxsutvcsreuwnuypwimfqmlcjucfzklkhdeaahurnrqalqrjzfrrsctbzygaktltyrvyyqsnjinwyghzmyqgdmhekpeulrnjj...
output:
201946
result:
ok single line: '201946'
Test #34:
score: 0
Accepted
time: 623ms
memory: 182276kb
input:
20 baaababababababbaaaabababaaaabbabbaaabbbaabbaabaabbbabaabbbabbaabbbbabaaaabaabaabbbbaaaabbaaaaabaaaabaabbbbbbaaabbbabbaaaababbbbbbbaabbbababbabaababaaabbbbaabbaaaaababbbabaaaaabbaabababaabbbbabaaaaaababbabbbbabbabaaaabbaabaabaabaaaabbbbaaabbbbabbababbbabbbabaaaabbbaaaaabbbababbaaabbbbaabbbbbbabba...
output:
187803
result:
ok single line: '187803'
Test #35:
score: 0
Accepted
time: 669ms
memory: 183716kb
input:
20 wighspqotssudabkedkygymrryunfudbdlkxbdnwxfqbitnmwxmeyyypysfgoihtuuqxxgtullvvgjhcivigwiyucdatnkmhefgblbxymtusedwozhxxrvruaunngbxkifnvhkwvfqolvmawvxtnunjuhwjnzizioofvabqgtgtpvtnqshfmwoidmssmatwohblhdepwmjnhcbavkfjgwslikfumysdfwombscxfnnopqomcwyksqvaaaxoaprflgtmaxmfkbwcrkqtgodaeabgcyvepmjduervefcqgy...
output:
265680
result:
ok single line: '265680'
Test #36:
score: 0
Accepted
time: 377ms
memory: 183416kb
input:
20 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
output:
1799368
result:
ok single line: '1799368'
Test #37:
score: 0
Accepted
time: 720ms
memory: 165180kb
input:
2 aabaaabababbaababaaabaaaaababaabaabaabaabbbbbbaabaaabaabaabaabbbbbbaaaabbbabaabbbabaaabbaabababbbbbbbbaaabbbbbaabaababaabbabaaabbbbaabaaaababaaaabbaaaaababbabbbaababaaaaaabaababaaaaaaaabbbaaaaaaaaaaaaaabaaaaaaaabaabbbaabbabbabbabbaabbaabbaababaaabbababbbbaaaababbbaababbaabbabbbabaababaabaababaaaab...
output:
92934
result:
ok single line: '92934'
Test #38:
score: 0
Accepted
time: 772ms
memory: 165128kb
input:
2 jcmgevxqwiaflstvldrnmkeoeczrruqbxfjdagtyptfcoyybepqqzvggxgxpcpsbubfxhyvyubbkbznfqdysyeywmxlrodslgxipyfougrgkstriwpavwatkzgbolwbrtjgtownxnthfoyqlqsimvbwuhakuwllrurllqakdwtlkrdvjvfvqiunruxlslwjhqwsgzcjvvwfpzdyxkwntqakmawglurskonqnpcknarecwezhaoasrmgrkmefgwpujijbmvqomwqjarsbguvxgcqrqwwwsnsexdhjazanvq...
output:
91737
result:
ok single line: '91737'
Test #39:
score: 0
Accepted
time: 315ms
memory: 162684kb
input:
2 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
output:
93662
result:
ok single line: '93662'
Test #40:
score: 0
Accepted
time: 778ms
memory: 175176kb
input:
10 cdvthwmepkhrkkvpucesqgrdwtzdvicynxrutfykridcsbrpfvhwdabzucdpkhpxhgtcospfashuvajdxqzarcclefcrosqvakyoenughdadgmgdchgvjiinpleddvbfhzuloqtvvtabfihkpnfaxqqmburgrslathljxehvahwhsftjszkpradswxaqrlqlvewukdpmlouftnomoydfajzzgzpxnhkilhcykskxiecburpkrtsuctvktkhitsqhzuflopjwwnysgneaiwumqpwlbetwwldxfiiuatqwh...
output:
735652
result:
ok single line: '735652'
Test #41:
score: 0
Accepted
time: 811ms
memory: 186632kb
input:
4000 fcrfjdagkknhhvvklrmnnnqcrmjnifrphkwsnyaxiqfpnczytnngbejusuhabapjkodzmgwvydmlfomabzhedsywmhyohqzreeqqmpnkuawcoicrhlwndwjsehilzjfdnxwcmjmjjklzsptcbrpenaytjgfjpmmfjihyuvhfguhyjacktrrgrpadyhmptaueldcfzjkfdrfptizmbqvvixyiekxzmudxxgcwrpdxilmcvnqweltokrwqdtpsnvpndulujpttchxxvotzbppmilcmguewpvjupuoalku...
output:
555122
result:
ok single line: '555122'
Test #42:
score: 0
Accepted
time: 754ms
memory: 184036kb
input:
4000 abbaaabaabbabbbbaaaaaabaaaaaaababbabbaaabbaaabbabaaaababaabaaaabbbbbbbbaabaaaaaaaaaababbaababababababaabbabaabaababbaaaabaaaababaabbabbabaaaaaababaaababbabbbbabbbbaaaabaabaaaaabaabbaaaabbbbbbaaaaaaaaaabbabbabbaababbaababababbabbbbbbbaaababbbaabbbabaabbbbaabbbabaaabaaaaabbabbbbbabbbaaaaaaababbab...
output:
777185
result:
ok single line: '777185'
Test #43:
score: 0
Accepted
time: 271ms
memory: 173204kb
input:
2 baaaaaaabaaabaaaaabbaababbabbababbabbaabaabbbbbbbbabbbabaaabaabbbbbbabaabbaaabbbabaaaabbababbaabbbabaaaabaabbaaabaaabbbbabaabbbbababbabaabbabbabbababaabbabbbaaabababaabbbbbabaabbaabaaabbbaababababbaabaaaabaabbbbabbaababbbbabbaaabbbbbbbabababbaaabbbbaaabbaababababaabbbbaaabaaabbbababbbbbababbbabbba...
output:
54
result:
ok single line: '54'