Binary Strings

AtCoder
IDarc127_c
Time2000ms
Memory256MB
Difficulty
Snuke has written on a blackboard every integer from $1$ through $(2^N-1)$, in binary. Find the $X$\-th lexicographically smallest string when seeing the integers on the blackboard as strings. Here, the input gives $N$ in decimal, but $X$ in binary. ## Constraints * $1 \leq N \leq 10^6$ * $1 \leq X \leq 2^N-1$ * $X$ is in binary. ## Input Input is given from Standard Input in the following format: $N$ $X$ [samples]
Samples
Input #1
3
101
Output #1
11

The strings written on the blackboard in lexicographical order are `1`, `10`, `100`, `101`, `11`, `110`, `111`. Additionally, we have $X=101(\mathrm{binary})=5(\mathrm{decimal})$. Thus, the answer is `11`.
Input #2
10
10100011
Output #2
1001001111
Input #3
1000000
11111
Output #3
1000000000000000000000000000000
API Response (JSON)
{
  "problem": {
    "name": "Binary Strings",
    "description": {
      "content": "Snuke has written on a blackboard every integer from $1$ through $(2^N-1)$, in binary. Find the $X$\\-th lexicographically smallest string when seeing the integers on the blackboard as strings. Here, t",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "arc127_c"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Snuke has written on a blackboard every integer from $1$ through $(2^N-1)$, in binary.\nFind the $X$\\-th lexicographically smallest string when seeing the integers on the blackboard as strings.\nHere, t...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments