CF2123C.Prefix Min and Suffix Max

传统题 时间 2000 ms 内存 256 MiB 5 尝试 1 已通过 1 标签

Prefix Min and Suffix Max

You are given an array aa of distinct integers.

In one operation, you may either:

  • choose a nonempty prefix^{\text{∗}} of aa and replace it with its minimum value, or
  • choose a nonempty suffix^{\text{†}} of aa and replace it with its maximum value.

Note that you may choose the entire array aa.

For each element aia_i, determine if there exists some sequence of operations to transform aa into [ai][a_i]; that is, make the array aa consist of only one element, which is aia_i. Output your answer as a binary string of length nn, where the ii-th character is 11 if there exists a sequence to transform aa into [ai][a_i], and 00 otherwise.

^{\text{∗}}A prefix of an array is a subarray consisting of the first kk elements of the array, for some integer kk.

^{\text{†}}A suffix of an array is a subarray consisting of the last kk elements of the array, for some integer kk.

Input

The first line contains an integer tt (1t1041 \leq t \leq 10^4)  — the number of test cases.

The first line of each test case contains one integer nn (2n21052 \leq n \leq 2\cdot 10^5) — the size of the array aa.

The second line of each test case contains nn integers, a1,a2,,ana_1,a_2,\dots,a_n (1ai1061 \leq a_i \leq 10^6). It is guaranteed that all aia_i are distinct.

It is guaranteed that the sum of nn over all test cases does not exceed 21052\cdot 10^5.

Output

For each test case, output a binary string of length nn  — the ii-th character should be 11 if there exists a sequence of operations as described above, and 00 otherwise.

Note

In the first sample, you can first choose the prefix of size 33. Then the array is transformed into

1 4 7 2

Next, you can choose the suffix of size 22. Then the array is transformed into

1 4 7

Finally, you can choose the prefix of size 33. Then the array is transformed into

1

So we see that it is possible to transform aa into [1][1].

It can be shown that it is impossible to transform aa into [3][3].

Samples

3
6
1 3 5 4 7 2
4
13 10 12 20
7
1 2 3 4 5 6 7
100011
1101
1000001

在线编程 IDE

建议全屏模式获得最佳体验