A7960 | TV Game
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
There is a new TV game on BerTV. In this game two players get a number $A$ consisting of $2n$ digits. Before each turn players determine who will make the next move. Each player should make exactly $n$ moves. On it's turn $i$ -th player takes the leftmost digit of $A$ and appends it to his or her number $S_{i}$ . After that this leftmost digit is erased from $A$ . Initially the numbers of both players ( $S_{1}$ and $S_{2}$ ) are «empty». Leading zeroes in numbers $A,S_{1},S_{2}$ are allowed. In the end of the game the first player gets $S_{1}$ dollars, and the second gets $S_{2}$ dollars.
One day Homer and Marge came to play the game. They managed to know the number $A$ beforehand. They want to find such sequence of their moves that both of them makes exactly $n$ moves and which maximizes their total prize. Help them.
One day Homer and Marge came to play the game. They managed to know the number $A$ beforehand. They want to find such sequence of their moves that both of them makes exactly $n$ moves and which maximizes their total prize. Help them.
输入格式
The first line contains integer $n$ ( $1<=n<=18$ ). The second line contains integer $A$ consisting of exactly $2n$ digits. This number can have leading zeroes.
输出格式
Output the line of $2n$ characters «H» and «M» — the sequence of moves of Homer and Marge, which gives them maximum possible total prize. Each player must make exactly $n$ moves. If there are several solutions, output any of them.
输入输出样例
输入 #1
2 1234
输出 #1
HHMM
输入 #2
2 9911
输出 #2
HMHM
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted