UberOA #18
Balanced Prefix Sets in a Permutation
估计中等可在线判题
For each k, given a permutation of 1..n, determine whether some contiguous subarray has a value set of exactly {1..k}, and output the results in order as an n-character 01 string.
This site's standard input/output is stated explicitly.
输入格式
The first line contains n, and the second line contains a permutation of 1..n. This site's range is 1≤n≤100000.
输出格式
Output a 01 string of length n, where the k-th character indicates whether some contiguous subarray has value set {1..k}.
样例 1
输入:
4
2 1 4 3
输出:
1101
样例 2
输入:
5
3 1 2 5 4
输出:
11101
样例 3
输入:
1
1
输出:
1
样例说明
Example 1: the positions are contiguous for k equal to 1, 2, and 4, so the output is 1101. Example 2: they are contiguous for k equal to 1, 2, 3, and 5, so the output is 11101. Example 3: the only element forms the set {1} by itself, so the output is 1.