当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6739:Invoker

题目描述
In dota2, there is a hero named Invoker. He has 3 basic skills in the game, which are Quas, Wex and Exort. Once he launches a basic skill, he will gain the corresponding element, where Quas gives "Q", Wex gives "W" and Exort gives "E".
Invoker can't have more than 3 elements simultaneously. If he launches a basic skill when he already owns 3 elements, he will get the corresponding element and lose the element he gained the earliest.
As can be seen, there are 10 unordered combinations of 3 elements in 3 types, each represents a special skill, which are as follows:

  • Cold Snap: unordered element combination "QQQ", denoted by "Y"

  • Ghost Walk: unordered element combination "QQW", denoted by "V"

  • Ice Wall: unordered element combination "QQE", denoted by "G"

  • EMP: unordered element combination "WWW", denoted by "C"

  • Tornado: unordered element combination "QWW", denoted by "X"

  • Alacrity: unordered element combination "WWE", denoted by "Z"

  • Sun Strike: unordered element combination "EEE", denoted by "T"

  • Forge Spirit: unordered element combination "QEE", denoted by "F"

  • Chaos Meteor: unordered element combination "WEE", denoted by "D"
  • Deafening Blast: unordered element combination "QWE", denoted by "B"

  • When Invoker owns 3 elements, he can launch the invoking skill, denoted by "R", to gain the special skill according to the elements he currently owns. After invoking, the elements won't disappear, and the chronological order of the 3 elements won't change.
    Now given a sequence of special skills, you want to invoke them one by one with using the minimum number of basic skills(Q,W,E) and invoking skill(R). Print the minimum number in a single line.
    At the beginning, Invoker owns no elements. And you should re-invoke the special skills even if you have already invoked the same skills just now.
    输入解释
    Input a single line containing a string s (1 ≤ |s| ≤ 100 000) that only contains uppercase letters in {B, C, D, F, G, T, V, X, Y, Z}, denoting the sequence of special skills.
    输出解释
    Output a single line containing a positive integer, denoting the minimum number of skills to launch.
    输入样例
    XDTBVV
    输出样例
    15
    
    提示
    One possible scheme is QWWREERERWQRQRR.
    
    来自杭电HDUOJ的附加信息
    Recommend chendu

    该题目是Virtual Judge题目,来自 杭电HDUOJ

    题目来源 642ccpcQHD

    源链接: HDU-6739

    最后修改于 2020-10-25T23:33:56+00:00 由爬虫自动更新

    共提交 0

    通过率 --%
    时间上限 内存上限
    15000/12000MS(Java/Others) 131072/131072K(Java/Others)