Task
LLM gives you a number and a sequence of natural numbers. Now, he wants you to find for each position in the sequence if there exists a subsequence with the following properties:
- Its length is greater than or equal to .
- , where are positions from the initial sequence used for the found subsequence.
- One of the chosen positions is and it is neither the first nor the last position in the subsequence (in other words, and ).
- If we consider the values at the positions, the sequence is a palindrome (for example, the sequence is a palindrome). A sequence is a palindrome if and only if and so on.
LLM quickly found the answers for each position in the sequence, now it's your turn to achieve what LLM has achieved.
Input data
The first line of the input file sirpal.in
contains , the length of the sequence. The next line contains the values, representing the values in the sequence.
Output data
The first line of the output file sirpal.out
will contain a binary sequence of length , where the value at position is if we can find such a sequence that contains position and otherwise. The values will be displayed without spaces.
Constraints and clarifications
- for each from to
# | Points | Constraints |
---|---|---|
1 | 12 | |
2 | 16 | |
3 | 28 | |
4 | 44 | No additional constraints |
Example 1
sirpal.in
5
1 2 3 4 3
sirpal.out
00010
Explanation
We see that position is the only one that satisfies the conditions. We can choose the subsequence formed by indices . We observe that it satisfies the conditions.
Example 2
sirpal.in
17
1 6 2 4 6 3 7 5 9 7 3 8 8 10 10 8 10
sirpal.out
00110011110011110
Explanation
For position (where the first is located) we can choose the subsequence . This is not the only option.