QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#803529#8420. CiphertextmasonpopAC ✓110ms12092kbC++141.8kb2024-12-07 17:27:262024-12-07 17:27:32

Judging History

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

  • [2024-12-07 17:27:32]
  • 评测
  • 测评结果:AC
  • 用时:110ms
  • 内存:12092kb
  • [2024-12-07 17:27:26]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int maxn=1e6+10;
int n,k,trie[maxn][2],fail[maxn],tot,ed[maxn];
queue<int> q;
char s[55][55],T[maxn];
int f0,f1,a[maxn],siz[maxn];
inline void insert(char ss[])
{
	int len=strlen(ss+1),now=0;
	for(int i=1;i<=len;i++)
	{
		int ch=ss[i]-'0';
		if(!trie[now][ch])trie[now][ch]=++tot;
		now=trie[now][ch];
	}
	ed[now]=1;
}
inline void build()
{
	while(!q.empty())q.pop();
	for(int i=0;i<2;i++)if(trie[0][i])q.push(trie[0][i]);
	while(!q.empty())
	{
		int x=q.front();q.pop();
		for(int i=0;i<2;i++)
		{
			if(trie[x][i])
			{
				ed[trie[x][i]]|=ed[trie[fail[x]][i]];
				fail[trie[x][i]]=trie[fail[x]][i],q.push(trie[x][i]);
			}
			else trie[x][i]=trie[fail[x]][i];
		}
	}
}
signed main()
{
	scanf("%d",&k);scanf("%s",T+1);n=strlen(T+1);
	for(int i=1;i<=n;i++)
	{
		if(T[i]>='A' && T[i]<='Z')a[i]=T[i]-'A'+1;
		else a[i]=26+T[i]-'a'+1;
	}
	int tsum=0,c1=0;
	for(int i=1;i<=k;i++)
	{
		scanf("%s",s[i]+1);siz[i]=strlen(s[i]+1);
		if(siz[i]==1 && s[i][1]=='1')f1=1;
		else if(siz[i]==1 && s[i][1]=='0')f0=1;	
	}
	for(int i=1;i<=n;i++)tsum+=siz[a[i]];
	//printf("f0 %d,f1 %d\n",f0,f1);
	if(f0 && f1){puts("-1");exit(0);}
	if(!f0 && !f1){printf("%d\n",tsum);exit(0);}
	if(!f0)
	{
		for(int i=1;i<=k;i++)
		{
			for(int j=1;j<=siz[i];j++)s[i][j]=((s[i][j]=='0')?'1':'0');
		}
	}
	for(int i=1;i<=k;i++)
	{
		reverse(s[i]+1,s[i]+siz[i]+1);
		insert(s[i]);
	}
	build();
	int now=0; 
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=siz[a[i]];j++)c1+=(s[a[i]][j]=='1');
	}
	for(int i=n;i>=1;i--)
	{
		for(int j=1;j<=siz[a[i]];j++)
		{
			c1-=(s[a[i]][j]=='1');
			now=trie[now][s[a[i]][j]-'0'];
			//printf("ch %d,i %d,j %d,now %d\n",s[a[i]][j]-'0',i,j,now);
			if(!ed[now])
			{
				printf("%d\n",c1+1);
				exit(0);
			} 
		}
	}
	puts("-1");
	return 0;
}

详细

Test #1:

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

input:

3
CACB
011
1
001

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: 0
Accepted
time: 1ms
memory: 7796kb

input:

3
ACBABCAACABCAACC
0
10
110

output:

-1

result:

ok 1 number(s): "-1"

Test #3:

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

input:

2
ABABABBAAAABAB
0
1

output:

-1

result:

ok 1 number(s): "-1"

Test #4:

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

input:

4
ACBDBCABCDBCABDBCABADBCDDACABCDBCDABCADBCA
01
1011
000
110

output:

128

result:

ok 1 number(s): "128"

Test #5:

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

input:

4
CADCCACCBD
1110
1111
110
0

output:

20

result:

ok 1 number(s): "20"

Test #6:

score: 0
Accepted
time: 1ms
memory: 7916kb

input:

4
CACBCAAABD
1101
0
111
1100

output:

23

result:

ok 1 number(s): "23"

Test #7:

score: 0
Accepted
time: 1ms
memory: 7972kb

input:

4
BBDBADDCDD
1000
1001
1011
0

output:

10

result:

ok 1 number(s): "10"

Test #8:

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

input:

8
GBHDHEHHBEAHBHFADAAGCHGBGFEGGF
001101
010
0111
1
00101
00100
001100
0110

output:

80

result:

ok 1 number(s): "80"

Test #9:

score: 0
Accepted
time: 1ms
memory: 7956kb

input:

8
FCGDGFBDBEEHCGEHDCEHGHGGGBEFEA
01111101
00
01111100
01100
1
01111111
01110
01111110

output:

51

result:

ok 1 number(s): "51"

Test #10:

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

input:

8
EDADDCAHEFFGCBCEADDHEAHDFAFEFH
0010
0011111
00111001
00111000
00111011
1
00111010
01000

output:

94

result:

ok 1 number(s): "94"

Test #11:

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

input:

5
CCACDEBEBEEECCECBBBCEEADDEABEEDCEDEACDBEBBEEAADBDD
10100
100
11
10101
0

output:

67

result:

ok 1 number(s): "67"

Test #12:

score: 0
Accepted
time: 1ms
memory: 7924kb

input:

5
CEEBCCEBEEACADCEADEDBCEDBBDEDBBECBADBCEBAEEBADBBCD
0
101
11
10011
10010

output:

97

result:

ok 1 number(s): "97"

Test #13:

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

input:

5
DCABBEDAEEABDADBCBCCDCCDEADACEDDDBBDABABACCBADADEE
10010
10000
0
10011
10001

output:

85

result:

ok 1 number(s): "85"

Test #14:

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

input:

10
GIJIEEHFJIGIEACDAJJBIHAGJBHGIHEDJGDAJFAEBIDAFIGEEBIIIEAIFEAHIIIDJIGBEIJCFJEHIHDAEEAIJAIAJGFIEAEIIAHB
1
00
0100
01011001
0101100011
011000
011001
0101100010
01101
0101101

output:

295

result:

ok 1 number(s): "295"

Test #15:

score: 0
Accepted
time: 1ms
memory: 7932kb

input:

15
HGAHKNOJNKACDMNHDJMCOFDEECACOHOAKNNCJCNKOGBJCLIODGHEAJHJENHNHNGGFKODNMCAGHNDOEMABNONBBFNNEACNFFDLDCI
10011110001
10011111
100000100
1001111000000
101001111
10011110110000
100111101100011
10000001
101001110111
1000001011
100111101100010
100000001
1001100
100111101100101
0

output:

515

result:

ok 1 number(s): "515"

Test #16:

score: 0
Accepted
time: 1ms
memory: 7920kb

input:

12
DAKEFECADKILCLIHADICADJEAKACKDDJKJALKLGAHDBFACLJKECILCELEAKCBBCAEBHGDAHDLEDICFHFAJCEKJDCCBGADIALIBFA
1011
0
1111
1001
101001110110
101000100001
10100101
101001100110
10100110111
101000100000
10100110000
101010001110

output:

406

result:

ok 1 number(s): "406"

Test #17:

score: 0
Accepted
time: 1ms
memory: 10260kb

input:

20
PIARCESBCFSMSDIGKFGMNCLMKEGFBTIKCTHOPKDDDJAKLBCPOGRPKIMKROEGPMHKIMATKNDHRNMTHSEPJEAGHBSIECEJIFIOTESHRGETJFTRIFICFHSDOSIFSLICSPRHPLKBRDTCGJJSPCECEOQAQJCJTFIATQIJCMDGSKFNMQNDQFGNNTCKJAMNTGRBACPGGMOTASQOQCQASKATNDPCQOCQPQOQNMIRKHCGSTKFRBNROGITPNPSPTQPSTEICOSHPEAECJNNHHRCRHERDLLHAQSNMRTGSQEKHQPRGRTSK...

output:

1327

result:

ok 1 number(s): "1327"

Test #18:

score: 0
Accepted
time: 1ms
memory: 7884kb

input:

5
ABEBEBEDEEDACADDDEAAAAAAEADBDAEDAAEDECDDDCDBCDACEBACEADEECBEDCEDDACABBCEEDDDDDDACCCADBDBBACDACDBEBCDCEBEEAEDCEEDBBEBDCECBECBBECBDBECDDBADBDEDDDEEABBADEBABBACDAEBAABDDACCCACECBBDDACCEECEBDAECDDDCBEAEDDCCBCEDDCECDABDEEEADADAACABCBBAABEBEEECEAADEDCBDDEBDBBAEABECCAEDBCEECEDBAAACEEDDBDDAEACDEDCADACBBAC...

output:

558

result:

ok 1 number(s): "558"

Test #19:

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

input:

17
GQKGLOEOAGAPGBLBIKLMBCFAHHNADNOAJHCAMADMKMKLGOLPOHMJEMIDFPEEQILGEANHFHQMCPAHCMPHHJLIPNGOOPMIFICIAOGGBPAMEEFFNLGOAOFQQBGOAEEPCBDDFJPHMJQFEGBDNFOKMKLPNABBGLHBPMPOEEDPPIICDLLPKMAHQNCMFBCFNFDCBPLNGKBDPBLNCQOAMHAMNLIQIQELHEPEFDKPGJMFDOFHOKBDKNAOGGGACKLDJEEFAACNQFFFHNQPDGBIAPJQGQLQBFAQPCKIEIFPQIKFQBAHL...

output:

1399

result:

ok 1 number(s): "1399"

Test #20:

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

input:

10
BFEAAAAAAEAEAFIFAAEFAAEHEEAAAAEAAFAAAHEEAAAAHEFAAAAAEAAFAEEHAAAAAAEEAAFAAAAFEAEFEFAHAHHEAAAACIAHEHAA
000000001
0000000000
00001
001
00000001
0000001
1
000001
0001
01

output:

8

result:

ok 1 number(s): "8"

Test #21:

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

input:

20
SALLEODOLOAOOEKJELLODALBOOEAOOLDNJELOEDRLOAOOOLOEDOOAOOOOAOOEOOAOOANADDJGDRGDJOOJAOOOEAAKLLNNJEDAOOOLDABODOAEAOLOALIELOLLAEODECDOCODAOODAJAOODJADLOAALAAOLAKOENDGODDOJJDKAOOAOOAOALNLDLAKADAAOEOEKNEAOOAALOLDOOAOOLABAAOABLLOLLLELALLLDLOALDODLJAEONONELEOOAAJALAADDKENOJLDCOCOLCDLLJDOOOOLODELDAOOEDAOAO...

output:

19

result:

ok 1 number(s): "19"

Test #22:

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

input:

52
SlPpeAAeerlepAQDPvhJRXpuBHpeDeeZuiXLJlDepRyyLLLoseJLRLLRZDRJABBLJGyDeleRJZuAsBAAeuLlDBZepBeRuDBrBppLRArJZJePeAyepRGeRprJLepeLhpGJeXLHABZeLypLPusrppJGhBeelKDegyAPJeprBLDepeeZLAppGARpDAJuvRleeDeBLLpGBaLJPuDRerAJlZpBeuyKJplReJlheZRpLZyJApeJieQgHlcZApDlABJHPUHpGsBJpeeJHeePRrAApRrUJeADRQpJsJuLsRAPJypg...

output:

44

result:

ok 1 number(s): "44"

Test #23:

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

input:

47
BQGeEbGDbQnbmIlQuuWIIWNumuIWQkbTIbQYeuQYlnmclDlYrYEeEbLWbYueNeQWlWeuQYcNppFpbWnQbeWbWplGbbpbceIQWmleWebLeQlEWWpQXenWWHpQkYnOeIlbbnlpGlbWbllENnYQQWIpebeWWIblGkQbElInlnLQnWWQbQlGeneGuGbeseemcnHeYQlWnEubucYbpWNrebpWbYIIbGQlnlEGQEGbYuIlpNcNNbrelNkWeGWQuQpQlLQbWcnEQbWnLWGkeEnGQbYQlrkuCuYYYWlNnluuGeYWm...

output:

47

result:

ok 1 number(s): "47"

Test #24:

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

input:

52
GgMXdKdDeXeDdjoDRzMjIzzkzzkRuPHeRLPuXHdzQzkjQKIXPeHLjjRzRzHDMWmeMdPdXKzduDmddKXkezHPpudguPPdHdduePojPKdPzXMzDLDjHdQHMgNXdjoHPuzMLzzzdHRjjoPXzzzjeDHXHRXXuXXjjDjdPzQHeHLKDWHdRBQXuPPMLdPdjdLjXajRPPzdPodLjgKKezguHRdIdzzzCgdzmMuKRRpouQXzRHzzPjKPPLKDKzKRzLLzBkPdPoRHPoDKPdmHzHLjPzupXHRezRuzjHQuLRQHdXRzZ...

output:

36

result:

ok 1 number(s): "36"

Test #25:

score: 0
Accepted
time: 6ms
memory: 7936kb

input:

48
gDRFHnhFPajbEBGQbBRBEKQEoaBQGafPHHDHPEPRHQPDFGvRGnRKGKaaHFBQQcGQDFRaZHoBRRGRDRRXBtGBDEatBcKaBGRZQBBRDQBaDtRGRBDREfQQDDGHGGhBFhaGDnKPvEvaBHnoQEZrZQBQERRBQHHDvHBRvGZBRPKYFBaDBRffBRBPHGDHEaHEYvLKQFPRKQGHrfcRrBKDRBrQDPhavZBvBBQRKQQKYEDGRBEHZvcQZQHFQBGQBRaBRnaBtQQZKQtRRGBaQQRaBRRRaRatHPRKZPaPnfHHbZnBC...

output:

44

result:

ok 1 number(s): "44"

Test #26:

score: 0
Accepted
time: 12ms
memory: 8000kb

input:

51
WotXatpnjEtaiUPMUtnpUaojMiMijxUMdnMnoaofinojEXXaxCUooKojaKajydMgMtjaMUxiajePjiaeKwawXMXMnMoaMdjfjohXienjKatFPjejaUaifjjMedeeMiKnnfjMaanoMwnnjoXijnSMFpadyHoMMfSifeexiaBnjhVjijwhatdMtjaiaoKanpdaajapjMewtXajjeUaapaofxfeKXjaKtXeopKihaMMjKaMSdnattMddwoinneMjtaBdKeaoKjUioZUinapMtiiKjvjMMaMaonnXpinUjopd...

output:

47

result:

ok 1 number(s): "47"

Test #27:

score: 0
Accepted
time: 56ms
memory: 12020kb

input:

50
sPPXSXMARRqRTRJSFBxStPtPMlRRPLtUOxPPxJUJPDWRtRtPXqRMtXRSRRRtqCSLPDPLJMtJqtqtqoUqLFXJWPRJjAqqxULRPXqnJRSJJqFUqRRqxxSMJoJDqqXBqSSXqtJqCJPAtBSxJJJRJvVOqtXJLRBtBBFLJqfJBqSJtxPUnJtqPqqoURqBtJRqRDSJLqJttXoFnLBLBttFtfSXtRqqPDPXAJJOBLPtPOxtBBJXPDqPqIXqBqDttUSJtRxPtROttDxUJnXFSJSUxLMMLRnDSnDMMtDoBJJJSMLtC...

output:

46

result:

ok 1 number(s): "46"

Test #28:

score: 0
Accepted
time: 64ms
memory: 9936kb

input:

48
cNMTRVnbMZVPRbRnVTbMTUMMCjPFFVTCRMMnbRqbVTHVNVHdRobjVVEIVTjMMdMNZnbRNMoNCpbRVMVNRNdMjIbHMMVPHjoaVjfnbojUHHbTNjNRPVIMNjTbHRNMUTMRdnHUFMTbdPMbHMTTNHUMjZHCMIUFQPbMMTdNbjVMMMCMNTTpUTVTTVjFbFMVjMjbVZIMNHdHHjRNHbMMMboiNnbTjZjjbdjbjbTeToUbRVjMRHToVCTRMjHFHojVEbRbjSUVnMCTUbTnRHVRpjUMZHbTCioUNCbjbFMPLsTHR...

output:

39

result:

ok 1 number(s): "39"

Test #29:

score: 0
Accepted
time: 78ms
memory: 9968kb

input:

51
UgVmrXrgXgWVYrXiXaeQZaHVYpWgXrVbRXQbpVasbVRXipbViipVXZYRRmXVxaRigwxawiXXwGQxiSVQNiibgRrVgiaRiaRgoXXaQiYSVNVAYYipiRaeRiXiQVVWiQVwQaXYgpQRXrgQgQaeVisXfGbXRiOxVxacQARaiAVNVYVaGVVwiQRGRioggXiXXXfpWgrgfVrSoYipsQiLiQwiRRgRRGVXAgZXXVQZgbaRrwWarewVZiYaiZZiXXRgbYGViGXXXZYbQXQiRXWRgiXYWQgQQQgYWiXxXXgQiiQYZ...

output:

44

result:

ok 1 number(s): "44"

Test #30:

score: 0
Accepted
time: 84ms
memory: 9856kb

input:

50
WcSSmvOSvSDLGcAOnAwIDSAYESQvEcCCmYCveSQODivEvwSACODwDcjnSOOmDwCYDEcDDYAOESoOvqSCAAYQcwDvDQYmiiASvASniiOYeSAYSDvSDwSmSnQSDcAajDSmvSGcAvSOoACmAOIASjcSwQSmCIcOcOvwLnSvmOjvOImYAOcYGiijCQADcQSjveSOniOJSxYvICIYSYGAAADDejDSvSmESiOAEDYOCDiAvSSDevvYcAiOYmDrDOvvvxASaivvOiDYAaCirOOGcSiiimOSCDeEYcwYvSIoASnLA...

output:

-1

result:

ok 1 number(s): "-1"

Test #31:

score: 0
Accepted
time: 104ms
memory: 12092kb

input:

52
IUFOtpyyFmypmrtYrYFoyUFjxOprOXFYopgFrYnyjUFFFrrxcOdFoyYUFFpYrYtUnyFnOttmFnFyYpYFmrmmtbDYOtmXtplorpFODmgnnmjFOrYYnFrlnoqnTmnfYrbPofFFmUyyYtxOFOtmXxrmgomrxpyrrbFrxrcmrpYJxnFrmrcyyFXrtXYpptYtymbXxTroOjOntmnrFmmFcdtyoFFmmynYXmtXoDyFFYnFlnoUtmFypjmmmonnxOrpoyrbmYXJytFpnpOtndtoJYttYprcbrFUyXrtYrmXcmnnF...

output:

40

result:

ok 1 number(s): "40"

Test #32:

score: 0
Accepted
time: 110ms
memory: 9980kb

input:

52
YLeCbPKKWeMgCefFgfKPWnnbignoMfodKrWnbfFiPvdKCMbgfMgEWffvfKWKfgCifeikCWfMbbnbMdkoviiFPnefgVfgiCWiTbKCffKffdCCgCiioWCtWCKTbgfrWgftTkPKKfWnrWdKWFetfMeCdEnidfofVKeKgiPFKKggKWbCifrorfFnCgfoffFrgefWbMgPXWffWTWgeCKogiWPVgiuknPKfPVgFgegMfgfgrgTrVoKeWvWiintfbAFgdeWfofWeWWMCgTrgdKAiiengeoMofgebrtfCrKiVfMPV...

output:

35

result:

ok 1 number(s): "35"

Test #33:

score: 0
Accepted
time: 109ms
memory: 9936kb

input:

52
uvExZWiiZXdZfiXwifvXMynheYvbYcyZeinvTyNeXvifXXEevvTvEvXbfiEyUXZfEnyEicZTEElnfvTETXXETytTvlyRZRjyZiYeYqvNvvfRTTeUZxvYvxyvhfEbYvijcGvRYTZYYyhZGYveittNvlnciifbifhYfhRffNEZfYfZEEhfbfRyEyvfZEhZTvbGMREyyyEMjvyvAexHvvZvcfvXiviefvvxGZiNfGxiXZyhqvTeyyWijnefivEETZZNffyXEZEETfZXdWtiRGfvEeyhjtciNEyTyZiWefYfh...

output:

49

result:

ok 1 number(s): "49"

Test #34:

score: 0
Accepted
time: 110ms
memory: 9964kb

input:

52
smSWatmPSgBlktdRThcldBuWkWRkVWStRttylkkWtRVdktVkVHHhvVlkBBlVWSabtWSVkctMmScHtWWvhRvkmWSSVVVVSktHcWtSRWWRbHtBvahlylSSSBkaRWBkVklWWclbykaHVtkllkTllWBkktmkchtHSVchmvVnWahWlTkvTllSVFakakHVSkdSmVlBlWfbnikmWzSltWWtWSlSRtekWhWVhdBkmShbdmkPlkWRWVcmcmSkWStvaVkbtkbaBtlWWvcTSTWWtdHkhllkmimlvkkHVllmklclBBVWa...

output:

42

result:

ok 1 number(s): "42"

Test #35:

score: 0
Accepted
time: 110ms
memory: 12024kb

input:

52
mzKhiIueYKWUCzXUniQGrhdhiQCQdKIlzdQYHiQYdjhQIXhQDIdlXIHKKeDKuKzUQiQhhuYKXihCHuIdXYHliiHXziOdTHKuQhKOHqQXlKIvidQXYOTrChlkilHhQhueIIhhYlQXXiXDlkHiYXXdIhKIdiHiDQdIqhRzQDDiDYilulRGezhXTQqHiYIXDQdYrriaThKYKhuDYQQvdhWQkhHKrdhhYllrYQOdiQiHDKIdAYIhHIulUHhhrihRIWOIQQhYiXdWibIKIHXeYhXliHXXYrAlTzzihhIKXQulQ...

output:

40

result:

ok 1 number(s): "40"

Test #36:

score: 0
Accepted
time: 110ms
memory: 11824kb

input:

52
jzySSINFhqDZNLLEpNuhDIVhLNLSKRDzLhFLVLLSNqRRKKNxDaLJDLSDZhIcFpxcSqPNhDNZIhctNRhNRRREqShDRRESDKRRNappthtxKqVhxSKxLIIFpDpSLcIDaSKRNCWEKxLNhINaIaqqaLLSZhcRxNSNNyLppDLVSxDLLLxIIaZNDKhSqDZIpqxZDZSLpDaIxRIpVNIRDhRRsDIZDLRuLNLzZDhLRVqaZaLRLLRDSRcqPaZIZhchaWLIRaLcRLqLIIWDaVVhRSLVLhhSNIpRhLDNNSZphRLLktIVI...

output:

-1

result:

ok 1 number(s): "-1"

Test #37:

score: 0
Accepted
time: 1ms
memory: 7888kb

input:

30
OLYQJQTSZEREEbELUUNDZSTTXKYWOBWQPWLTYZGDZcHMQOJdGXGUDBPMIYRbLYRIcJaJEbQLKTcXQSYUPPIPYCTZJRNcPKMVLHTCBWaNLPEFGFaPcKEZYDCMLaFZGQDZRKBcQGLYHTAOUUEGMPcBYYKOcGJTMYdIYGQTXQcASMPHVBZAHDRXDKGZGLTZIJbAYQIGQdUJRbaVdDaWCZTZGZZWZMcbdKWXILLaATTaTRBQMXNKcBbELCIECbIJJTFTBKDFNRCSDJHMHNBABWHMLDYFAJSDCLNdaaZdPTWXJ...

output:

2207

result:

ok 1 number(s): "2207"

Test #38:

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

input:

52
EYgXjypLAFbzBZvslOuzjAgbnlHUMQsqRqIDfDcijszZaHpiIUKuHcFXVnfEhQUbJALacgfLeFfTclsjGteLZFTCTVoCtCSEYwBNUPaOGMOufgCKgBbYxcHdqCyucGWWPtOjACfCXFpUbXlLdjRTzNXThMfUjhVcGiCjRBQsUUwfMrNEuVbLDyVVJldIUWuEARgTCbMbSVvOaLAPWhKUtdgnFSeTMyxkBMKmGszAcghdhDcETIiuBuRdbPDHHwGcWceBfBOLaQMoKkYlxTrtfUvqLEvepIeZbFQuLpEUN...

output:

3526

result:

ok 1 number(s): "3526"

Test #39:

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

input:

6
FDBAFFCEFBBBFDCCBEEACFCEDCFEBDFEFECBBBDACCDFFEAEABCECEDAAFFACFDFAEBCDFDBECEDBFCFEAFCECDAAEAACFABFECEDBEEDFBCFAFBFDFFBABBDFFCDABECFBBCAFDDFEDBCCFEBAFBACFBCAFEECEFBECDBBCAFADEECFCABBFFEADFCAAABCDADACEDDEBBDBACFDCFCCAAEFDDABFBCCABFDCECEFAFFDADFDCDCDCBEBCACBFEEBAABEFFEDBCBADDBABDDFFECBFDBBCBACBCFCDBCE...

output:

1282

result:

ok 1 number(s): "1282"

Test #40:

score: 0
Accepted
time: 1ms
memory: 9792kb

input:

4
CACCCBACABDCBADADCDCAABCBCBABACCADBDBCADCCDADDCCABDABACDDDADCCBCCBDBBDBDAABBDACADCBDDCCADBDDBDCCBABCDDAAACDBBDBCADDBBDBBBDDCDAAAABBDBBCCBACBCDBCDCDBBADAADCABCBCCBBCCBBCAABBCBBACACDCBACDCDABACBDCBDDCBBACCDBCCBDBBDBDADACADBBBDAAABBCCACBABADDDDBBBABCCDBDBACCBADBBCAACBAABBDDCCABAACAABADCCBDAABBABBCDCB...

output:

-1

result:

ok 1 number(s): "-1"

Test #41:

score: 0
Accepted
time: 1ms
memory: 7960kb

input:

47
uuDnYhComnMiMagPjiVRFHcpitrmIQoWcNKGWPhuuJNIRqnaipTscOlrRCfrdfmXIWdctaDmkooeBmoCWaCLcrKuEPXCVkVonAhLCjZpJPKBdrnPAgBbcEUTDWUHRDKUPSPGuKKZEFUKdRCFPHrhmrSsGWCGUJDJJjMlYloIBCclUfEktZlErYGTIrHraWHUacoEfBkTbZEjgjjlVIbpIAImOjPlGTcXtAaFsMsNgaWIIXdQjbAoaMWsXTiIMBeNQKWMmSoEJQMOSGXjLJDjZDeRFFSpskRSetlMtnIEf...

output:

6341

result:

ok 1 number(s): "6341"

Test #42:

score: 0
Accepted
time: 1ms
memory: 8204kb

input:

16
NKBJPCEKLEFLDINNJFAAJLKDMBEIJNKHJLLAEKADFKIKDNGLMANJGLCEPLMEOABGDNIOBGLHPDJFMNCIFNEMPPOIGCCGJINLLJMEJDNAANOHLMPBBEFMKKEFGNFHMIDANBLLBAJOOAOOBLIJHPIGGFHOHLNBFKAAIGPODMBDDJCCIEHADBCCAGCGEAKDBOBEGBABKLDJIEHADGNKIEONELOBMOENCENONHDHPDMDCKOKGEEHDPCAOKDEFNLBNDDKKHBCDHLJHBLDABFMGEBKMEEKFLGPIBMFPFJFJMGKK...

output:

5298

result:

ok 1 number(s): "5298"

Test #43:

score: 0
Accepted
time: 1ms
memory: 8204kb

input:

3
AAAACCACBCABAACCBABAAACBABBBBCACCACABBABBCACBCBBBBACCAABBBBAABBCBABCABAABABBCBCAACAAAACACABBBACBCABBABBCAABBCBABAABAABCABABAACBCACACBBBBBBCACCCBBBBCCBAABAACACCABACBABBBBABBCBACAACCAACBABBABCABCAABBCABABABABAAABABBCCACAAABACBAAACBCABBCBBBCAAACCCBCCACABCACCABCBBAACACBACAACCBBBBCBCABCCBCCCACBBBABACAB...

output:

3043

result:

ok 1 number(s): "3043"

Test #44:

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

input:

49
VpLwTfqKJXJagjewmJmlEBBiKBTIgrXthVtJBBpaCjJMPTgDBTgqnYmZiYojMfkuZqPMPEZTdSbtSeKfCZieABoLOotABRtwRXnLpTwCjAFPKcVjgtJVDoFnZZNrAuuHYKRibGHTKjKGakIEZMJhNVksqNNlRorPGaibrDOOQdqUIjUwBeEfWjLXnBtdiliFRXEYjUhhKZcSnAGXdWiQNrKBupJnNKgCvKKitmHnfZmWmCpuMMThpdCBuaGNMReHtUhNDjdsaekcgnCkedNtkOrVCVMkDhmKHLYEVBuQm...

output:

18657

result:

ok 1 number(s): "18657"

Test #45:

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

input:

30
JNFbSNLTaFAGVdLVAIPdHGOGIdDKdAATFUaMWFUVTGNHWLIaCDHQOFBARDDcXWUVYdYNWQUBBPMGVbDUTHZSWIVVLILQUUGWBEREAaRaIBMHJWcbTXSNDRIdaCNQOWaQFQUEXVNIZFAKPCcDRASHXKYZNYWNPSOJaELOaWWWdMPUNTPGaAZbWNPOVBNcYMcZHJQFBFBQaSDTAOVASKGYNVWKBDbOXDCGXLXENHIWTNMdYTJPPYYFGOOHAWEXEHbSdMbWZdJKXAKMbTXFdVTMdEaZTFLaBPcScIFOBQBcb...

output:

19500

result:

ok 1 number(s): "19500"

Test #46:

score: 0
Accepted
time: 1ms
memory: 7932kb

input:

10
EJIAIDAGHCEAGBHJGFEIAGFCFIIGGJGFABECCGDFCACEIABHAHHAGAHHHGFADIJHJBFFFHJDJAJHHGIJHDBJFCBAGBHCCIBIJDFFAEHCEGHGBDIHCAFBCGCJJAGFHIBBIBEDEAIAGJCJAIIBHACHAAEDHADFBJEIBIGGJCHDGJGGFEGDIBDJAJAEIBAJEJJDBEAIBBDCEGEADFFBAJBAIEHHGJIGADABGGIAFICBGBCBEAIEFFGEGACDGCJFFAJIDECCEJBGJBDECAGIEFAJDEEEIHEFDAHAAACHIIGJG...

output:

11593

result:

ok 1 number(s): "11593"

Test #47:

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

input:

29
LPDYTRWCWEOSZGUDCRKGJSHDLMDaLOGFUAWabDZBcOMLLHZSNGCOUUKJNMaUMbRCKAbbUMZIPPbEOBSEMPYDBAYNRLbcCATDUFaGWGDSWJDOJVcZXEHWMHWAMMOYSLJFbLAOJFZMCELGLKIZVNZANVLARXXGZZKPcPIcBZaYSZEOITccLCXDZWHDFMOLMIFaZENQbKRZMOZGMPPASWcBQZLCScESHRMGPSUWKZXcUbWBIJWOYaJALHDbCZHNAbJRSYZQVKMYUKTQYcPHMPVcBJVOSaJVQFXEbARQUEMQD...

output:

26002

result:

ok 1 number(s): "26002"

Test #48:

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

input:

44
JCBXfBdAhOOYjpUVdCqHLEWrUGhBeUJAqWDJYQrcFqPFJfInJKQHFIOkklQKYFqpqDIYrmVbNMEjFVMddEJDYlLKhDRDFVLpTgIUSjbCggmcOrOkpVGVbHKaLNZYreOrfKgJfAhAqNNWrVZHWRSaPfcbaffRTCZgKFQLXHTWTIEHPYkGrkLBIrEeHAUWIIfTeUrmqGJqcBIpDmBSkJFUdJhelRLaYELpNQJSHLrnoHMhrZPCedBacgNDISdbpSfdnRYTXYCWIHQTaIhnkTaPrMKSZWmPgfaPGKBQaQQpS...

output:

27615

result:

ok 1 number(s): "27615"

Test #49:

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

input:

30
CRbAYcXVPZRALNVKbKTKFCATAKVaBWFGDYCPJAMAWCLJGYJHFdaabKGQUCFSETPTUADLWdcOONPMSQCLXYAaQEDOAJcETXIKaaYPLPGMEWVKKbOEHRSUMCFEIFPOSYXDJPIcALWQbJWDMNWBFdBELXMOIUMOXCMSURSTZJHTBdCCUBEPVLVLYcKBcIIFWQbMXOUHPJTZBTWNJXaWNXDVTOKXPbBIOJGVMVbZGFWccRKPNHPJWZFFOCAQPbFDdVZMbVIYcKJEKQKQIDDCKWMWPBJSQXBLZQTAWLYARHadB...

output:

53312

result:

ok 1 number(s): "53312"

Test #50:

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

input:

15
GKLJJMOODLDIMCAJBGLMHBNMLHOBKJBNJJLGJEGDNMKFLFNFLGHNJGCFIMAFHMFKKGCKIFDMIHBLKICFHBEDBOCMNDICGNOAILDMKILOMBIKHBBIHDBAGLKOHNBMDIBNGFDIIHHOFNMGMGBJHDKDEGNLCCHGKFHAFKLFLIJLMBMENJCNLMGFNEJMFNBBJNGECCMMJFOADLKKFMGNILLINGECIMJNGAMAGAGEBFMGKIKFGMKLNJCKEKMFMNEFEMNNIILKJOMHBNKEGIMIBJLECGMKNBFKMKIDDNGMJCIIL...

output:

45037

result:

ok 1 number(s): "45037"

Test #51:

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

input:

6
DAEBCCCECDDABBFDABAACADEAAFBFCCAEBDAFABAFFBDCCEECACADEADEBBAEEEEAFEFFFCBEABCFBCDBECFDDBCBBFACEAAFBDBEDFCCCCBAEBFAFACCCAEBCCEFAEFADDECCFDEFCEBABFEACDEFFBBFCDFDEADBDEDCBFDADDEDDCAACAADEFDAFACEAFDFBFDDBDEDCAFAEEDABFCBABCFADADFCADFBDEBDEABCEAEEEDCEBACAACCDBDDABEFDDFEFCECBFCFFFDDCDDFBDFDBDBBCFEEFCDFFCB...

output:

21742

result:

ok 1 number(s): "21742"

Test #52:

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

input:

52
OzBcxuyatimLLZDxCsArBwICmjObMTOgnzQBWODRYzMTffOrTfEdkvScEgEMwZjOVRGWzBebSVjDtmLFEqQoVsTaXPDXkmRtSvuItkyDbLcJRemTVzprNSuGgVsyEByepLANQuCKcVxPqxzcrgmOcJlaNQqUoTIhOiFUzsQATzyEceSyUnvudriXoZKWjTxeJdgFUWOxOFVlFDffyeFZFxqgcxjZNWKYOPBMAHxtEvFIvUFsYTTSwSVndalGMTXJyntSKvRvFJDjnGmsywOmVvzqjmtQqfsHXToCUHOoq...

output:

170276

result:

ok 1 number(s): "170276"

Test #53:

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

input:

16
PFLOJEBBFCIBFKFAJDGEGGDOIHGIOBOADMDLIHMJEOBKOGBOAFJECLDBKDHGEPDIHJOCHPOHBIIMEJKHOHDEDJDODBNIGMHFIGBMFNPBONFNHPIENHNHLEIMDPOGCCDAJNJOLBBDNHHJALFJFDGGNKBHFLMBDPJKCPPDPMKNEDGIPPPKNCCFHAEMAMEOJDDBEABGKCNKIAHPENKMLFAJANNJDBBNLJPDJPFDLOEHONNFKBFDCNDCLIMAEHEGNENALOJCCNFGIELPEMBDFODMPLOINCIOJGIHDCBGJLCNI...

output:

108589

result:

ok 1 number(s): "108589"

Test #54:

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

input:

5
EDDDBEBBAABDBCABEEABEAEBECCEDDECCCAEBCBEBDABECACBEEBCCACABCBBCDBBADCEDEBAAEAEAADEABCADCACCAABBCDCDCBBEADECAACAEAEDCBBAAAEBCCEBBBBCCCBEDADCBCADCCAACBBCBAECDBEDECAADCDDBCDBDCACEDBCDECEDBEDEDDCDEADBBDBBCEBBCCDDAEBDEADCDEABBACDDCEEEDECEEDACECEAEBBECCAEDAEBEBDCECCBCBABABDDAEAAAEDEDEACABBBDEECBEAABABDAA...

output:

89782

result:

ok 1 number(s): "89782"

Test #55:

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

input:

30
SaSDcWHIEGZUEQMQFdBWTEYQQEPPbXHPKBJUZFAYTAPQTASPAJbHQZFGCbbHFcNYHUECLQLFASYKcPANIJOHdWTcCaQOYXGOWQXBXUHSFOAOPbVAXFaKJHbLCYUEZNJTWJCIaIbUbNKKVXPRKbdEcZWLZXIFbRHEBHFJdMYUaIGOQKRIFDAAXDaOFEIYZFVcJBZdZbcaWFIaLFQDIcNYKZdHAJOQKdVAKAYRXKYRFCPQJAMbcdWBQEUPQCHBCRbRYKCRPVVDZGVVTTEGbGKOYBANLaJEcGUYQTKaQRNVK...

output:

232012

result:

ok 1 number(s): "232012"

Test #56:

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

input:

52
jteKTmXtBNYcOKhKahctVJdiEmuLkfZbQpYGkXuPjOfBntXqJbxryNzxgIVMpLOvKagTvzstDiuzeQnXSIxNGvdikqlazqMCREtiavoHALUVYEIdjMxeueISUYyrNoYAEDpijvXJTXtsztEgePaixrETDigGXAhYIXzAxSAWYdxSJqrYMayuLOwyztrQKwcYltbzQBkwbpNDiUashrHdFScrWjHoVdMDLUpvFnGFMDrBwehelIXnRQBCdqAjMqiAKUlJzlnDiHsDhejQXEkxRfXSUpmPQlZQttDsCjWIW...

output:

269137

result:

ok 1 number(s): "269137"

Test #57:

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

input:

6
EEEFFFCFBECDCDDEBDAACFAFFFAABFDFEAFBECFABCBBABEBCFFBEFBCEFCEEFBBEECECCBCECAFFCFFDBCDCCFAFDDBFDCBDDACADCDCFACEBDCCDBDFAFDCEDEBBFBCAFEAEBBCFADDDAEDEAAEABBEFFEBBCCBAFDFBAEDBCAEBAECDACACDDDFDCCFCCCEEBCADBDAACAAEADBADFEACCCAAAFBBDCCBEBDFFBEAFCBCEFAEDBABDDBFAADBCBFEBEDCCBEADAFADCCFFAEEEFACCEBEFEADDCDAAE...

output:

158295

result:

ok 1 number(s): "158295"

Test #58:

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

input:

30
QEKHFFEBJGQXXQUEUWIQGVBTWCFdUHCBBBdXFGOEHOJJadObMZXOOAJRXbVQPNXcRHMFSSDYFaAKNcWMNRccQOGSEPKEPJcSIQcdNaJEZdaEEGCQVWNRHcQRYXFJYVEKGTaLXLWXZMBLFPCASHUbbDDEBSBLBZGRCTCVHBdSCRFTFBBMANEWHDVCMWLKLWFcQMUCKcGIQUFIWWNPKQGMaUJEHXUaTbZILGcSObbGDJNaRAGRQFZcERRdScbJAYZScJORQFBDXPGVSDdPScNNIDHXUATGcGUJNcdZPWVYC...

output:

974403

result:

ok 1 number(s): "974403"

Test #59:

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

input:

15
FNIBNFCKEHCIBOGDBDALIFNNLGMEOKNCGCINMKABNJIEAKELDJEBMDFHLGIDDNNMHNDEFDHIGFBJNFNGMCDFAJGJDBOCCNLAFIHCFLHGDIMMHCLNHHKLBAGLIIGGCMEFCCGGIHHFEAGNGJEIELOLGJDBCALDDHBOJMDGJABDGFAOOCHJNAFHEIFNKFLNNMOMLHMADJJNDEINDLIFFMHHEGDNGINBKCICEIHMBFCAAGNKJGJEAFHEJKODAOLMFAGEIKCDLJNHFNGJAIJHCAEDKAKACJIFAOJFJAKOHCLDM...

output:

813039

result:

ok 1 number(s): "813039"

Test #60:

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

input:

6
BCACDBEBBDCFEEDAAEAAEFFEBEECEEFCCCFDBAACECDBBCDDEFDFFECCDCCADDEFCCFADBDBDBEFDECCCADEAADABFDDCFEFBDFFEFCBAFDAADFAACFAFDCDBACCAAECAFCEDAECFDDFEFEDAAEDDFFEDCADEFEECBCAFDEACBDBEAFAAEEBCEDEEFDDDACECEDBFFEEFADCCADDCECCBCDAFDCAEBEEFBCFCECEDFEFFDDAEDAAACFBCFDBEEAABFEEBFFEBCBDEFFCAFDDECFFCDFBEEADEBDEBBCCDC...

output:

400264

result:

ok 1 number(s): "400264"

Test #61:

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

input:

52
KbCzXhNnxBkVevzVCDveopBGZdNGzbqrTPVIcIpQjgifYunVnDmzcRuiYuAyAZPJpEqZvPEtQQXHoNmhCOZaqvMRjbUTdCdOTSxQPtOdiHHpjgxjUwNOQvPdWIRoXlGdiWadAUWGCYKCkYDmmacRFxKzANvCsvbUCWJXGFFuQngmnVNeBWsvKIVXOjyAecXyXASCaDGnLIZIZvTGQuPsuxxZoVajgwHeRvNTTYuHpbxEllcwRJrZBLqZiijVzyOFLXqFVJYHAJEWnkFyqjaBXzfOLEFhqmacegxRkFxcN...

output:

2837583

result:

ok 1 number(s): "2837583"

Test #62:

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

input:

16
INAFCOGOLLLAKCBPMBMDLBBPMLAGOPPFHPCAHJNOJFPCPAKNKENAABBMONHCOLMHKAMDCALLHDKOKEHGMAKIFCDBIENDFJCDMJICMELAHPECDDKPEEAGBEOJDMBOFKIGCJHHJKLECLFIKJBAHOEPFCDPGLFHGJBAGNPGAOCPPNLLKKFCNPOCGPBFADFGKBJGHLMPMPCIEINOCANENCJLFKJIDMOOMMCENOEMNDLICKICMBGGBFKFONIAOAEGHIJBEBIGOFOPGLMMJOAAMBEGIGGEAEIAJFODDFIKNLHNJ...

output:

2092774

result:

ok 1 number(s): "2092774"

Test #63:

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

input:

5
BDADECCBBDBBECEBCADECBAAEDCBECBEEBCDECACBAECBACADDADDABDBEEDDABDBCBAEDADACDADCCCCDCBEADEACEEABDBEBDDBCABEDBDCAEDBCAEDDAEDDBCCCDBACBDCBECCBBBBBCBACEBAEEDEAEADCEDECAEEADDDACAAABBECECDEAADBAABBDDCBDCDCECDDEACDDDBBCCDABCACDCBEDCAEBCCABDCECEADDAAEDCAECCEADCAEBADEEBCDEDCAEEBAACBACCCBAAECCABABDEECEEBDAAD...

output:

1101439

result:

ok 1 number(s): "1101439"

Test #64:

score: 0
Accepted
time: 10ms
memory: 9940kb

input:

30
NLDPJDcWEYLFdPbHLFLFAZWQNJCOKNaIBcCRBYbbYcOSUHRVUIVYGdROVJUCDIFQXWWEXLPdQcaIOGIWHdGROKSTRCMTdMVDTdDYZMVZWbFFZQAAQBVQMAQUMOCNOVBXIRQNHBJKcCJLRRPBVAQDAZCaHSSNSbEQDIHDIKddVEFOESCHJVNSTJbLROAWQRUaVYYJYVUKaaaHDFaXWQSNDaTXDUdQQTSLaAICZMZRGXYALVFWGAZYJYDHNRFDAKQcVdKKOHGKGSWLVcNOKYNTJOQFDDDIFcYBHUMPTWECK...

output:

5763210

result:

ok 1 number(s): "5763210"

Test #65:

score: 0
Accepted
time: 15ms
memory: 12024kb

input:

52
EmtGfqJplTHOwXUGpJfVmftyDhfkJuGCrVlDbinZEsMZBQCErEBUdJjRUvmfOIMWsvmCEUahZASdyvGbnDVKffJujadWgCPJyxjBsTPIFgXcGxYWMjhMVRhluwMWugqepBiKuXMHcoFZFVVGXczVXRxFhXGtiTRyuwJTKlbVtQNFLvIrvPodqRYzltltjGJYdKUmQYgopYOWAAtEyefwQNaOJonNhNkVNvpjvdBevIKxcnUSUBiqyocYyFcxwFVpXLukhXsvnPHrnRGNuCvfJaJuHZKWEJdDeapCVrcYX...

output:

6137396

result:

ok 1 number(s): "6137396"

Test #66:

score: 0
Accepted
time: 12ms
memory: 12032kb

input:

6
CFBEFDFBFEEAAECBDDAEEFDDAEEFEADCDDBEBFCDDBCFECBACDABACFEAAEDBDFABCCEEACABCABDEEBAEBBEEFFCADFECBEAABEBBAADEBDCBEEBACEFDEABAFEECBAABBAFEABEAFBDDADFEDFDADFBCACDEAEACAEFCBACCCFEFBADCAABEBDABAEDECBAFFAFCBDBEECBAEEEEABFBDECFDDFFEDAACDDDDCAEDEDCABCBBECAACDAEDCCCCBEABBFDDCEFBACADDDCDFDFDADBCBEFACBBFFFCEFF...

output:

1833374

result:

ok 1 number(s): "1833374"