QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#849447#8668. 回文路径liangzn100 ✓157ms11668kbC++145.8kb2025-01-09 15:26:482025-01-09 15:26:49

Judging History

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

  • [2025-01-09 15:26:49]
  • 评测
  • 测评结果:100
  • 用时:157ms
  • 内存:11668kb
  • [2025-01-09 15:26:48]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n;
string s1,s2;
const long long INF=2e9+5;
long long has1[N][2][2],has2[N][2][2],flag=26,mod1=1e9+7,mii[N][2],mod2=998244353; 
long long quick_pow(long long a,long long b,int flagg){
	return mii[b][flagg];
}
inline long long gethas1(long long l,long long r,long long flagg){
	if(l<1 || l>n || r<1 || r>n){
		return INF;
	}
	if(l<=r){
		if(flagg==1){
			long long has=has1[r][1][1];
			long long hass=has1[l-1][1][1]*quick_pow(flag,r-l+1,1)%mod1;
			return (has-hass+mod1)%mod1;
		}
		else{
			long long has=has2[r][1][1];
			long long hass=has2[l-1][1][1]*quick_pow(flag,r-l+1,1)%mod1;
			return (has-hass+mod1)%mod1;
		}
	}
	else{
		if(flagg==1){
			long long has=has1[r][2][1];
			long long hass=has1[l+1][2][1]*quick_pow(flag,l-r+1,1)%mod1;
			return (has-hass+mod1)%mod1; 
		}
		else{
			long long has=has2[r][2][1];
			long long hass=has2[l+1][2][1]*quick_pow(flag,l-r+1,1)%mod1;
			return (has-hass+mod1)%mod1;
		}
	}
} 
inline long long gethas2(long long l,long long r,long long flagg){
	if(l<1 || l>n || r<1 || r>n){
		return INF;
	}
	if(l<=r){
		if(flagg==1){
			long long has=has1[r][1][2];
			long long hass=has1[l-1][1][2]*quick_pow(flag,r-l+1,2)%mod2;
			return (has-hass+mod2)%mod2;
		}
		else{
			long long has=has2[r][1][2];
			long long hass=has2[l-1][1][2]*quick_pow(flag,r-l+1,2)%mod2;
			return (has-hass+mod2)%mod2;
		}
	}
	else{
		if(flagg==1){
			long long has=has1[r][2][2];
			long long hass=has1[l+1][2][2]*quick_pow(flag,l-r+1,2)%mod2;
			return (has-hass+mod2)%mod2; 
		}
		else{
			long long has=has2[r][2][2];
			long long hass=has2[l+1][2][2]*quick_pow(flag,l-r+1,2)%mod2;
			return (has-hass+mod2)%mod2;
		}
	}
} 
int anss;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	cin>>s1>>s2;
	mii[0][1]=mii[0][2]=1;
	for(int i=1;i<=n;i++){
		mii[i][1]=mii[i-1][1]*flag%mod1;
		mii[i][2]=mii[i-1][2]*flag%mod2;
	}
	for(int i=1;i<=n;i++){
		has1[i][1][1]=(has1[i-1][1][1]*flag+(s1[i-1]-'a'))%mod1;
		has2[i][1][1]=(has2[i-1][1][1]*flag+(s2[i-1]-'a'))%mod1;
		has1[i][1][2]=(has1[i-1][1][2]*flag+(s1[i-1]-'a'))%mod2;
		has2[i][1][2]=(has2[i-1][1][2]*flag+(s2[i-1]-'a'))%mod2; 
	}
	for(int i=n;i>=1;i--){
		has1[i][2][1]=(has1[i+1][2][1]*flag+(s1[i-1]-'a'))%mod1;
		has2[i][2][1]=(has2[i+1][2][1]*flag+(s2[i-1]-'a'))%mod1;
		has1[i][2][2]=(has1[i+1][2][2]*flag+(s1[i-1]-'a'))%mod2;
		has2[i][2][2]=(has2[i+1][2][2]*flag+(s2[i-1]-'a'))%mod2;
	}
	//s1 奇 
	for(int i=1;i<=n;i++){
		int l=1,r=n,ans=0;
		while(l<=r){
			int mid=(l+r)/2;
			if(gethas1(i,i-mid+1,1)==gethas1(i,i+mid-1,1) && gethas1(i,i-mid+1,1)!=INF && gethas2(i,i-mid+1,1)==gethas2(i,i+mid-1,1) && gethas2(i,i-mid+1,1)!=INF){
				ans=mid;
				l=mid+1;
			}
			else{
				r=mid-1;
			}
		}
		int nowl=i-ans,nowr=i+ans-1;
		l=1,r=n;
		int ans1=0;
		while(l<=r){
			int mid=(l+r)/2;
			if(gethas1(nowl,nowl-mid+1,1)==gethas1(nowr,nowr+mid-1,2) && gethas1(nowl,nowl-mid+1,1)!=INF && gethas2(nowl,nowl-mid+1,1)==gethas2(nowr,nowr+mid-1,2) && gethas2(nowl,nowl-mid+1,1)!=INF){
				ans1=mid;
				l=mid+1;
			}
			else{
				r=mid-1;
			}
		}
		anss=max(2*ans+2*ans1-1,anss);
	}
	//s2 奇 
	for(int i=1;i<=n;i++){
		int l=1,r=n,ans=0;
		while(l<=r){
			int mid=(l+r)/2;
			if(gethas1(i,i-mid+1,2)==gethas1(i,i+mid-1,2) && gethas1(i,i-mid+1,2)!=INF && gethas2(i,i-mid+1,2)==gethas2(i,i+mid-1,2) && gethas2(i,i-mid+1,2)!=INF){
				ans=mid;
				l=mid+1;
			}
			else{
				r=mid-1;
			}
		}
		int nowl=i-ans+1,nowr=i+ans;
		l=1,r=n;
		int ans1=0;
		while(l<=r){
			int mid=(l+r)/2;
			if(gethas1(nowl,nowl-mid+1,1)==gethas1(nowr,nowr+mid-1,2) && gethas1(nowl,nowl-mid+1,1)!=INF && gethas2(nowl,nowl-mid+1,1)==gethas2(nowr,nowr+mid-1,2) && gethas2(nowl,nowl-mid+1,1)!=INF){
				ans1=mid;
				l=mid+1;
			}
			else{
				r=mid-1;
			}
		}
		anss=max(2*ans+2*ans1-1,anss);
	}
	//s1 偶
	for(int i=1;i<n;i++){
		if(s1[i-1]!=s1[i])	continue; 
		int l=1,r=n,ans=0;
		while(l<=r){
			int mid=(l+r)/2;
			if(gethas1(i,i-mid+1,1)==gethas1(i+1,i+mid,1) && gethas1(i,i-mid+1,1)!=INF && gethas2(i,i-mid+1,1)==gethas2(i+1,i+mid,1) && gethas2(i,i-mid+1,1)!=INF){
				ans=mid;
				l=mid+1;
			}
			else{
				r=mid-1;
			}
		}
		int nowl=i-ans,nowr=i+ans;
		l=1,r=n;
		int ans1=0;
		while(l<=r){
			int mid=(l+r)/2;
			if(gethas1(nowl,nowl-mid+1,1)==gethas1(nowr,nowr+mid-1,2) && gethas1(nowl,nowl-mid+1,1)!=INF && gethas2(nowl,nowl-mid+1,1)==gethas2(nowr,nowr+mid-1,2) && gethas2(nowl,nowl-mid+1,1)!=INF){
				ans1=mid;
				l=mid+1;
			}
			else{
				r=mid-1;
			}
		}
		anss=max(2*ans+2*ans1,anss);
	}
	//s2 偶
	for(int i=1;i<n;i++){
		if(s2[i-1]!=s2[i])	continue;
		int l=1,r=n,ans=0;
		while(l<=r){
			int mid=(l+r)/2;
			if(gethas1(i,i-mid+1,2)==gethas1(i+1,i+mid,2) && gethas1(i,i-mid+1,2)!=INF && gethas2(i,i-mid+1,2)==gethas2(i+1,i+mid,2) && gethas2(i,i-mid+1,2)!=INF){
				ans=mid;
				l=mid+1;
			}
			else{
				r=mid-1;
			}
		}
		int nowl=i-ans+1,nowr=i+ans+1;
		l=1,r=n;
		int ans1=0;
		while(l<=r){
			int mid=(l+r)/2;
			if(gethas1(nowl,nowl-mid+1,1)==gethas1(nowr,nowr+mid-1,2) && gethas1(nowl,nowl-mid+1,1)!=INF && gethas2(nowl,nowl-mid+1,1)==gethas2(nowr,nowr+mid-1,2) && gethas2(nowl,nowl-mid+1,1)!=INF){
				ans1=mid;
				l=mid+1;
			}
			else{
				r=mid-1;
			}
		}
		anss=max(2*ans+2*ans1,anss);
	}
	// s1-s2
	for(int i=1;i<=n;i++){
		if(s1[i-1]!=s2[i-1])	continue;
		int l=1,r=n,ans=0;
		while(l<=r){
			int mid=(l+r)/2;
			if(gethas1(i,i-mid+1,1)==gethas1(i,i+mid-1,2) && gethas1(i,i-mid+1,1)!=INF && gethas2(i,i-mid+1,1)==gethas2(i,i+mid-1,2) && gethas2(i,i-mid+1,1)!=INF){
				ans=mid;
				l=mid+1;
			}
			else{
				r=mid-1;
			}
		}
		anss=max(anss,2*ans);
	}
	cout<<anss;
	return 0;
} 

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 30
Accepted

Test #1:

score: 30
Accepted
time: 1ms
memory: 3812kb

input:

1000
mfmlkrasfiudkzrjzyrlbpitvzfrlmjdzsurtdcmnqpsyfgobbstvplqylvciloomaljyssxtrrccywyirfvlcnchwkfwbdaoxzpfpvlruptganojnfxmnlqetptmlmoyluxvaipghtlaszoozscdmjomobyzboqqmvqjpbfjsoczhkwrlcauzjceqikbaeuiqahnldpqmohfjfzgkbfdbqnoxispkejvpncwsyelebqumapgbfdrjvuaxaphnkciwzkruijmanwslkwosgyfhwbnsthhtxrhrzlgtt...

output:

6

result:

ok single line: '6'

Test #2:

score: 30
Accepted
time: 1ms
memory: 3760kb

input:

1000
wvitzoxwlmhexjuqvoxksetoupgkhattucdzfevqorkdlsymjuvhobdrjsodtipwpfhipsdnyvqtsbbasrrvyybijzmpwseckztnpnkqswgkaeivflhwevhxcchjsnelqcixexkntwiuolsditpdwypgerzijziyrgqkwuucnqaehuwkpyrmwewjitvsaebyytznbtnkulnepceeloyjpfhcdpqfqhvzsmkcynjwztmkbnqaxnikfuiutocahdfbvsgdskgwqmzizzjlbqxnngftdohetabpjzpqzyc...

output:

7

result:

ok single line: '7'

Test #3:

score: 30
Accepted
time: 1ms
memory: 3756kb

input:

1000
abababaabaababbbbabbbbabbbbbbabbbaabbbaababaabaabbabbbbaabbaabaaaabbaaabbbbaaaaaabbbbababaababbaabbbbbbbbabbaababbbbabbaabbbabaaababbaababbbaabaabaababaaababbaaaababbbbbaaabbaabbaaabbaaaaabaaaaaabbbbbaaabbbbbaabbbbababaabaabbbbaaaaababaaaababbbbbbaababbbaaaababaabaabaabaaaaaabbabbabbbbbbbbbbabb...

output:

28

result:

ok single line: '28'

Test #4:

score: 30
Accepted
time: 1ms
memory: 3824kb

input:

1000
ababbababababbaababaaabaabaababbaabbbabaababbaaababbabbbbaabbababbbababbabababbaabbbaababbabaaaaabbbbbaaaaaaaaabbbbaabbbaabbababaaabababbaaaabababbbaabaabbabbaabaaaaaaabaaabaaababaaaababbaaabaabbbbbbaabbabaaabaabbbbabbababbbaaaaabbabbaabbaabbaabaaabaaabbbbbaabaaaaaababbbbbabbbabbbabababbbbbabaa...

output:

27

result:

ok single line: '27'

Test #5:

score: 30
Accepted
time: 1ms
memory: 3700kb

input:

1000
abbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbababbabba...

output:

987

result:

ok single line: '987'

Test #6:

score: 30
Accepted
time: 1ms
memory: 3812kb

input:

1000
aaaaaaababbabbabaabaaaaababaaaaaabaabaaaabaaaaaaabbbabaabbaaabaaaaaaabaaaaaaaabaaabbaababaaaaaaaaabbaabbabbaaaaabaaaaaaaabbaaabaaaaaaaaaaabaabbbbbaaaabaaaaaaaaabbbaaaaabaaabaaaaaaaaaaaaaababaaaaabbaabbaaaabaabaaaababaaaaaababaaaaabaaaaaaabaaaababaaaabbaaaabaaaaabaaaaaaaabaaaaaaabaaaaaaaaaaaabaa...

output:

45

result:

ok single line: '45'

Test #7:

score: 30
Accepted
time: 1ms
memory: 3692kb

input:

1000
aaaaaabaaaaaaaababaaaaaaababaaaabaabaaaaabaabaaaabbaaaaabaababaaaaaaaaaaabaaaabaaaaaaaaaaaaaaaaaabbaaaaaaababaabaaaabababaaaaabbaaaaaabbababaaabbaaababbaaaabbababaaaaaaaaabbbaaaababaaaaabaaaabbaabaaaaaabbaabaaaaaaaaaaabaaaababbaaaaaaaababbabaaaaaaaaabaaaabaaaaabaaaaaaaaaaaabaaaabaaababaabaabaab...

output:

45

result:

ok single line: '45'

Test #8:

score: 30
Accepted
time: 1ms
memory: 3808kb

input:

1000
aabaaaabaaaabaaabaabbbaabaabbbaaaaaaaaaabaaaaabaababaabaabaaaaaaaaaabbabbaaaaaaaabaabbbbbaaaabbabbbaaaaaabababbaaaabaaaaaaaaabaaaaaaaabaaaaaabbaaaaabaaaaaababaaababaaaabaaaaaabaaaaaaabaaaaabbaaaaabaababaaaabbaaabbaabaabaaaaababbababaaabbbabaabaaabaaabaababbabaababaaaaabaaababaaaaaaaaaabbaaaabaa...

output:

36

result:

ok single line: '36'

Test #9:

score: 30
Accepted
time: 1ms
memory: 3776kb

input:

1000
aaaaaabaabaaaaaaabaaaaaabaabaaaaaaaaabaabaaaaaaababaaaaabaaabaabaaabaaaaaaaaaaaaabbbbbabaaaaaaabaaaaabaaabaaaaabababaaabaaabaabaabaaaabbaabaaaaaaaaaaaaaaabbaaaaabaabbabbbaaabbbabaababbaabaaaabbaaaabaabbbaaaaaaaaaabaabaaaabbaaaabbbbaaabaaaaabaaababaaaaaaaaaabbabbabaaaaaaaaaaaaaaaabaababbaaaababa...

output:

50

result:

ok single line: '50'

Test #10:

score: 30
Accepted
time: 1ms
memory: 5844kb

input:

1000
aaccbdbabdaaddabaabaaaacbbccdbabbaacabcdababdcacadababaadaaaadabacababcdbaabaaaabdbabbdcaacccaaacababaacbcacaaabbabbaaabcbaaabaababbaaacbaacaaacabdccbbbaabaccacadbbcaabacadaababbaaabababbacaabbaaabcdaabaaaaaabaababaabcabacaabacaaaaaacaaabcbcabcbbcbbbaacaadadbadbbadcabababcabbcbbdadbdababaaadcab...

output:

20

result:

ok single line: '20'

Subtask #2:

score: 20
Accepted

Test #11:

score: 20
Accepted
time: 86ms
memory: 11544kb

input:

100000
ibhqhodaqcwqggmckoemulhkgbfidceskhefhsonccepfodalabaqgobpgcnaervbccadkbtsdigsoqochklocgbjjqcdhwrlacamprsoilyhiwkkjalicedhbxajrkhjgivjhnfdibkdwtexnnriegejazmohlfijbeigfmpngncokxhifjfuwuogccdfglfbxobnarmgfhgpnjjewicgfhcmfbbnjbbjjtbprnagpchcihcihfhcikeaecefdgeegtzlfdolhfieahiehdfcaflmndmcojceblf...

output:

9

result:

ok single line: '9'

Test #12:

score: 20
Accepted
time: 83ms
memory: 11600kb

input:

100000
fruiifpdggdnsbgamakpjipicaidfdjpffioqcwioaafbpdagmbbakqpekjabcljockpvcifilcjakhcboolgjbnmmrbeawcjopbccjgncdaucighprheiaqofriccfdbydbhijeelbthsmqbhcddlfemqkvdbflkdrifckarqwlaafifmqibssfukblchalkzdefnccaiabrhcrmisdeiqddccrqhiiwcqqakbfhebkiecahgdlibhgmegkfbuibcarcbajpdeboigeoctdljmqeckdfqahiecla...

output:

9

result:

ok single line: '9'

Test #13:

score: 20
Accepted
time: 83ms
memory: 11616kb

input:

99999
biwnbsgdlxognjnepijlgbfbbahicjfqhdhcielcovdflacbrgcfapifaylqfmvipcccoofthuutfheboncacenchdgfljpidjbasdsikduidkbdqckmlnbfaidlincqkccbbpmnqnpbjoclgeduitraqmdfgdqinhddgberlbnlgggoafgqllbifekoccpgemcgdiiackkcfjgddhieabhzdjfwegcbuncdadebglitgwcbpmclfijmqtbbnbbrcehhanjgbddiaoimmkehtloreemecckjejifck...

output:

11

result:

ok single line: '11'

Test #14:

score: 20
Accepted
time: 85ms
memory: 11544kb

input:

99999
chgjcjipccsmclcpjqmbrcpaqdggbdodxbcejbklpjhkefeidkjojjjbljhtykbcdgnnjeictgjgliegyfilmlkqkgddpefibjusamblbpqfbbvcfkgfagikbujlbjvenjbmcadceadnltdeksatckmkjkscojeqbpaaglggxhideqhkhibchdasadfggcoihhcwlphbeevohhohtthepedqfggbdglidnatocrkhnkijraddqbesaiajimdhdmvbgodlcglqqmkeehcfabeaatjdinzhijewfoxhh...

output:

9

result:

ok single line: '9'

Test #15:

score: 20
Accepted
time: 114ms
memory: 11596kb

input:

99999
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

99999

result:

ok single line: '99999'

Subtask #3:

score: 50
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Test #16:

score: 50
Accepted
time: 81ms
memory: 11628kb

input:

100000
vucutyzmjlnyadjbpqkrlqvzuponzxrvqsqqgbemhzjftdkksfgspeuonmjwlbirvszhcafcxpeubixvxetwyyqmftbobhodwaiwrcwdvddohalyqgaatvpflorvjypszbvzpwiaxxgievaozquixcndkxqfxcxaiygyqcgdebogwzquvqfljgjcvvhpirfzqlkwctibngdsffpormliyhrkcbxwxoaoovaawldfenziwnlahllzhjsvdhzekcqekayusmvzrgsdiiymjxfiddhawhgxathvnsedf...

output:

10

result:

ok single line: '10'

Test #17:

score: 50
Accepted
time: 86ms
memory: 11548kb

input:

100000
fotxrzsqxuaaiiqmiymhtfdipylgdmxizgzqrgbrmdemonbisusgbmmsgtyoaqgdmxwoxayxkszpvpypzjoapilopvhyiyhckcccaalqriunudgfifgvdiufjtukpsmdfjjzftszwizrwoxuqsujchtrywpiiineoscbvarbalizfyydbctxpuwndzgshavpygfcmxkorbcppbatauqqkumaqsjcupnihewaukjajqgdvatobxjgdcbevlxpkjdvpofwtctivkexpwnbwvwbhcmlivuvifpptiupy...

output:

9

result:

ok single line: '9'

Test #18:

score: 50
Accepted
time: 138ms
memory: 11608kb

input:

100000
baaabababbbaabbbbaabbabbababbbbbaaaaabaabbbbbbaaabaabaaabababbabbabbaababbaababbbabaaaaabbbabbabaaaabaabbbbababaaaaabbbbbabbbababbbbbaaabbaaabaabaaababbababbabaaaaaaaababaaabaababbbababbbbabbbabaaababbababbbababaabbaabbabaaaabaaabbbabbaabbabbbbbbabbbbaaaaaaaaaaabbbaabaaaabbbabbbaabababbbbaabb...

output:

40

result:

ok single line: '40'

Test #19:

score: 50
Accepted
time: 142ms
memory: 11604kb

input:

100000
babbbbaabaaaaaaaaaabbbbababababababababbabaaabbaaaaabaaaabaaaaababaabaabaabbbbabbbaabababbbaaabaaaaaaababaabababababbaabbbaabaabbbbbbbabaabbaabaaaababbbaabaaabaaaabbabbababbaabbabbbaabbbaababbaabaabaabbabbbabaaaaaaaaaabaabbabaaaaababaabbababbbabababbbbabbbbababababaabbabbababbaababababbbbaaba...

output:

43

result:

ok single line: '43'

Test #20:

score: 50
Accepted
time: 155ms
memory: 11612kb

input:

100000
aabaabbaaaaabbbbbaaaaaaaaaaaaaabbaaaaaaaaabaaaabbaaaaaabaaaaabaabbaaabababaaabbaaaaaaaaaabbabbbaaaaaaabaaabbbaabaaabaaabaaaaaaaaaabaabaaaababaaaaaabbaaaaaaababaabaaaaabababaaaaaaaaaababaaaababbaaabaaaabaaaaabaababbaaaaabbaaabaabaabaaaaababaaaaabbaaaabaaaaaaabaaaaaaaaabaabaaaaaabaababbbabaaaba...

output:

75

result:

ok single line: '75'

Test #21:

score: 50
Accepted
time: 153ms
memory: 11664kb

input:

100000
aaaabaabaaabaabbaaaabbbaaaaaaabaabaabaabaaaababaaaaabaaaaabbabaabbaabaaaaaabaaaaaaaaaaaaabaabbabaaaaaabaaaaaaaaaaaabaaaabbbabaaaaaabaaaababaaaabaaaaaabbaaaaaaaaabababaaaaabaabababaaabbababaaaaababababbaaaaaabaabaaaabbababbbaaabaaaabaabaaaaabaabaaaaaabbbaaaaaaabababababbaaabaaabaaababaaaabaaaa...

output:

58

result:

ok single line: '58'

Test #22:

score: 50
Accepted
time: 157ms
memory: 11548kb

input:

100000
abbaaaaaaabaaaaaaaabaaaaaaaaaaaaaaaaabbabaaabaaaaaaaaaaaaaaabaaabbbaabaaaaabaaaaaaabaaaaabaabaabaaaababaaaaaaaaaaaaaaaaabaaabbabaaaaaaabaaaaaaabaaaaaabaaaaabaaabbaaaabbaabbaaababaababaaaaaabaaaaabaaaaaaaaaaaaababaaaaabaaaaaabbbabaaaaaaaaaaaaabaaaaaaaabbbaabaaabaaabaaabbabaabaaabbabaaaaaaaabba...

output:

67

result:

ok single line: '67'

Test #23:

score: 50
Accepted
time: 155ms
memory: 11664kb

input:

100000
bbaaaaabaaaaaaaaaabbaabaaaaaaabbbaabababaaababbaaaabaaaaaaaaaabaaaabbaaaaabaaaaaabbaabbbbaaabbaaaaaabbabaaabaababbaababaaabaaaaaaaaaabaaaaabbaaaaabbaaaabaaabababbbaabaaaaabaabaaaaaaabaaaaaaabaabababbbaaaaaaaaaaaaaaaaabaaaaaaabaaaaaababbbababaabaaabbbaaaaabaaaaaaabaabababaaaaaabaaaabbaabababaa...

output:

55

result:

ok single line: '55'

Test #24:

score: 50
Accepted
time: 118ms
memory: 11668kb

input:

100000
cabcacbbacbbaacbaabbaabbaabacdcadbbccabbccbbaabacacbabaccbaabbbaaabaddbcaccdcaababaaabbbbbcdacaabababcbbcbcabbbdbbbcadaadabcabbacabbdbbcaaabacaabbabbabacbabbabaadabbabdbabcbdcaacaddbbbabdabaaabcabcababbcbbaaccabbbbacaabbacdaaaabaaaaccaaabaaccbaccbbababdacaacabcaaabbaaacbcbaaabcaaabcaabbabbcad...

output:

25

result:

ok single line: '25'

Test #25:

score: 50
Accepted
time: 108ms
memory: 11600kb

input:

100000
abbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbababbab...

output:

96421

result:

ok single line: '96421'

Test #26:

score: 50
Accepted
time: 0ms
memory: 3612kb

input:

5
pkusc
pkukp

output:

6

result:

ok single line: '6'