Data Encoding
Given a string S, your job is to encode it into a new string T using given charset C. To make the decoding easy, each original character X in S is encoded into a string Y made up of characters in C. What's more, for two different X1 and X2, Y1 must be different from Y2 and all its non-empty prefixes. What's the minimum possible length of T?
Input
There are multiple test cases. Each test case contains two lines, S and C. The length of S will be at most 100000. The length of C will be at least 2 and all characters in C will be different.
该博客讨论了一种数据编码方法,其中给定字符串S需要使用字符集C进行编码,要求编码后的字符串T中每个原始字符的编码都不同且其所有非空前缀也不同。目的是找到使T最短的编码方式。输入包含字符串S和字符集C,输出为T的最小可能长度。示例输入和输出展示了具体操作。
订阅专栏 解锁全文
620

被折叠的 条评论
为什么被折叠?



