CF31E.TV Game

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There is a new TV game on BerTV. In this game two players get a number AA consisting of 2n2n digits. Before each turn players determine who will make the next move. Each player should make exactly nn moves. On it's turn ii -th player takes the leftmost digit of AA and appends it to his or her number SiS_{i} . After that this leftmost digit is erased from AA . Initially the numbers of both players ( S1S_{1} and S2S_{2} ) are «empty». Leading zeroes in numbers A,S1,S2A,S_{1},S_{2} are allowed. In the end of the game the first player gets S1S_{1} dollars, and the second gets S2S_{2} dollars.

One day Homer and Marge came to play the game. They managed to know the number AA beforehand. They want to find such sequence of their moves that both of them makes exactly nn moves and which maximizes their total prize. Help them.

输入格式

The first line contains integer nn ( 1<=n<=181<=n<=18 ). The second line contains integer AA consisting of exactly 2n2n digits. This number can have leading zeroes.

输出格式

Output the line of 2n2n characters «H» and «M» — the sequence of moves of Homer and Marge, which gives them maximum possible total prize. Each player must make exactly nn moves. If there are several solutions, output any of them.

输入输出样例

  • 输入#1

    2
    1234
    

    输出#1

    HHMM
  • 输入#2

    2
    9911
    

    输出#2

    HMHM
首页