cswork / OA打开练习工作台

UberOA #42

Get Balanced String

估计中等可在线判题

考点(AI 标注)原地数组双指针滑窗

The array is a permutation of 1..n. For each k, determine whether some contiguous subarray contains exactly 1..k, each once, and output n values of 0/1 in order.

This site has made the standard input and output explicit.

输入格式

The first line contains n, and the second line contains the permutation; 1≤n≤100000.

输出格式

Output a 01 string of length n.

样例 1

输入:

4
4 1 3 2

输出:

1011

样例 2

输入:

3
1 2 3

输出:

111

样例 3

输入:

3
2 3 1

输出:

101

样例说明

Example 1: k=1, 3, 4 qualify; for k=2, 1 and 2 are separated by 3, so output 1011. Example 2: every prefix qualifies, so output 111. Example 3: 1 and 2 are not adjacent, so only k=1, 3 qualify; output 101.