P26736 [AtCoder] JOI Sort
普及+
题目描述

Problem Description

Given a string \( S \) of length \( N \). Each character in \( S \) is either J, O, or I.

You want to rearrange the characters in \( S \) to satisfy the following conditions:

  • For every pair of characters J and O, J appears before O.
  • For every pair of characters O and I, O appears before I.
  • For every pair of characters J and I, J appears before I. (Corrected on December 2, 2020)

When given the string \( S \), create a program that outputs the rearranged string \( S \) that satisfies the above conditions.

Input Format

The input is given from the standard input in the following format:

\( N \) \( S \)

Output Format

Output the rearranged string \( S \) that satisfies the conditions.

Sample Input and Output

Sample Input #1

6
JIOIJO

Sample Output #1

JJOOII

Sample Input #2

4
OOOI

Sample Output #2

OOOI

Sample Input #3

10
OIJJJIOIOI

Sample Output #3

JJJOOOIIII

Notes/Hints

Constraints

  • \( 1 \leq N \leq 100 \).
  • \( S \) is a string of length \( N \).
  • Each character in \( S \) is either J, O, or I.

Sample Explanation 1

The rearrangement of JIOIJO to JJOOII satisfies the conditions.

Sample Explanation 2

The given string might already satisfy the conditions. Not all strings contain all three characters J, O, and I.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
6 JIOIJO
样例输出
JJOOII