ReevoOA #2
Balanced Numbers (Permutation-of-[1..k] Subarrays)
估计中等可在线判题
You are given a permutation p in which each integer 1..n appears exactly once. For each length k=1..n, if some contiguous subarray has an element set exactly equal to {1,2,…,k}, the k-th character of the answer string is 1; otherwise it is 0.
The catalog's original examples and outputs are kept; this site explicitly defines the permutation domain as 1..n and adds n≤2000 to match the O(n²) algorithm and the I/O. The claim "any single element is balanced" in the original example explanation is imprecise: by the set definition, only the value 1 is balanced for length 1, but a permutation always contains 1, so the existence output is still 1.
输入格式
The first line is n, and the second line is a permutation p of 1..n. Bounds on this site: 1≤n≤2000.
输出格式
Output a 0/1 string of length n; the k-th character from the left corresponds to length k.
样例 1
输入:
4
4 1 3 2
输出:
1011
样例 2
输入:
3
2 3 1
输出:
101
样例 3
输入:
2
2 1
输出:
11