#C1274. Smallest Lexicographic Binary String

    ID: 42200 Type: Default 1000ms 256MiB

Smallest Lexicographic Binary String

Smallest Lexicographic Binary String

You are given a binary string s of length n. The task is to generate another binary string t of length n which is lexicographically smallest possible while satisfying a special condition: t must not be immediately followed by its complement. In this problem, the condition naturally holds when you construct t by arranging all 0s first and then all 1s.

Task: Given the number of characters n and the binary string s, count the number of 0s and 1s in s. Then, construct the string t by writing all the 0s first, followed by all the 1s.

Note: The lexicographical order here means that 0 is considered smaller than 1 and hence any string starting with more consecutive 0s is lexicographically smaller.

Examples:

  • For n = 4 and s = "1001", the output should be "0011".
  • For n = 6 and s = "110010", the output should be "000111".
  • For n = 5 and s = "11100", the output should be "00111".

inputFormat

The input is read from stdin and consists of:

  1. An integer n representing the length of the binary string.
  2. A binary string s of length n, consisting only of characters '0' and '1'.

outputFormat

Output to stdout a single line containing the lexicographically smallest binary string t constructed by placing all the 0s first followed by all the 1s.

## sample
4
1001
0011