問題一覧 > 通常問題

No.3629 Maximize Subsequense Mex

レベル : / AI推定難易度 : 2350 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (AC するまで非表示) / 解いたユーザー数 25
作問者 : 👑 loop0919 / テスター : ぽえ
お気に入りにしたユーザー ProblemId : 12294 / 自分の提出
問題文最終更新日: 2026-08-17 21:48:01
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 509 (順位表) の他の問題:

Problem Statement

You are given a positive integer $N$.

For a string $X$ consisting only of digits (any of 0123456789), define $\mathcal{P}(X)$ as the set of all possible values obtained by interpreting a non-empty (not necessarily contiguous) subsequence of $X$ as an integer.
For example, when $x$ is 102, we have $\mathcal{P}(x) = \{0, 1, 2, 10, 12, 102 \}$.

Also, define $\mathrm{mex}~\mathcal{P}(X)$ as the smallest non-negative integer not contained in $\mathcal{P}(X)$.

Let $M$ be the maximum possible value of $\mathrm{mex}~\mathcal{P}(S)$ over all strings $S$ of length $N$ consisting only of digits.
Present $1$ string $S'$ of length $N$ consisting only of digits that satisfies $\mathrm{mex}~\mathcal{P}(S') = M$.

You are given $T$ test cases; answer each of them.

Constraints

  • $1 \leq T \leq 1000$
  • $1 \leq N \leq 5 \times 10^5$
  • The sum of $N$ over all test cases does not exceed $5 \times 10^5$
  • All inputs are integers

Input

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

$T$
$\mathrm{case}_1$
$\mathrm{case}_2$
$\vdots$
$\mathrm{case}_T$

Each test case is given in the following format.

$N$

Output

Output the answers for the test cases in order, separated by newlines.

If there are multiple strings $S'$ satisfying the condition, any of them will be accepted.

Sample

Sample
Input
3
3
1
12
Output
102
0
214567893012

For test case number $1$, when $S$ is 102, we have $\mathcal{P}(S) = \{ 0, 1, 2, 10, 12, 102 \}$. Therefore, $\mathrm{mex} ~ \mathcal{P}(S) = 3$.

In fact, this is the maximum possible value of $\mathrm{mex}~\mathcal{P}(S)$ for strings $S$ of length $3$.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。