VIDEO - Video game combos

题意翻译

视频游戏组合 贝茜正在玩电子游戏!在游戏中,三个字母'A','B'和'C'是唯一有效的按钮。贝西可以按照她喜欢的任何顺序按下按钮。但是,只有Ñ个不同的组合可能(1 <= N <= 20)。组合表示为长度在1到15之间的字符串S_i,并且仅包含字母'A','B'和'C'。 每当贝西按下与组合相匹配的字母组合时,她都会得到一个组合。组合可能会相互重叠,甚至同时完成!例如,如果N = 3并且三个可能的组合是“ABA”,“CB “和'ABACB',并且贝西按下'ABACB',她将以3分结束。贝西可能不止一次地为单个组合得分。 贝西当然希望尽快获得积分。如果她正好按下K个按钮(1 <= K <= 1,000),她可以赚取多少分? 由 @谜之系统 提供翻译

题目描述

Bessie is playing a video game! In the game, the three letters 'A', 'B', and 'C' are the only valid buttons. Bessie may press the buttons in any order she likes. However, there are only N distinct combos possible (1 <= N <= 20). Combo i is represented as a string S\_i which has a length between 1 and 15 and contains only the letters 'A', 'B', and 'C'. Whenever Bessie presses a combination of letters that matches with a combo, she gets one point for the combo. Combos may overlap with each other or even finish at the same time! For example if N = 3 and the three possible combos are "ABA", "CB", and "ABACB", and Bessie presses "ABACB", she will end with 3 points. Bessie may score points for a single combo more than once. Bessie of course wants to earn points as quickly as possible. If she presses exactly K buttons (1 <= K <= 1,000), what is the maximum number of points she can earn?

输入输出格式

输入格式


输出格式


输入输出样例

输入样例 #1

3 7
ABA
CB
ABACB

输出样例 #1

4