#Lutece2037. 这份喜欢是否传达到了呢
这份喜欢是否传达到了呢
Migrated from Lutece 2037 这份喜欢是否传达到了呢
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
『 这种感觉,淡之又淡,如一连串海中跳跃的浪花,轻轻地抚摸着岸沿,浓时亦浓,似一道道如雷的惊涛,拍岸而起直入云天 …… 』子辉
提笔写道。
“好像太过稀松平常了些?不合她的口味吧”
“她好像蛮喜欢 01 序列的,但写成 01 序列好像仍然不够出人意料呢,毕竟她见了那么多二进制串了……”
“有了,三进制!我设计一个三进制字符替换表,然后按表替换,越短越好。”
“哦,还有,任意一个字符的编码不能是另一个字符的编码的前缀,不然就无法辨认了。”
Input
第一行一个数 ( ),表示情书的长度
第二行一个只包含小写字母的长度为 的字符串
Output
一个数,表示情书编码后的最短长度
Samples
6
abbdcd
8
10
aaaaaaabcd
12
Note
样例 1:a=01、b=2、c=02、d=1 样例 2:a=0、b=10、c=11、d=2
Resources
2018 UESTC Training for Dynamic Programming