欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF2123C.Prefix Min and Suffix Max
Prefix Min and Suffix Max
You are given an array of distinct integers.
In one operation, you may either:
- choose a nonempty prefix of and replace it with its minimum value, or
- choose a nonempty suffix of and replace it with its maximum value.
Note that you may choose the entire array .
For each element , determine if there exists some sequence of operations to transform into ; that is, make the array consist of only one element, which is . Output your answer as a binary string of length , where the -th character is if there exists a sequence to transform into , and otherwise.
A prefix of an array is a subarray consisting of the first elements of the array, for some integer .
A suffix of an array is a subarray consisting of the last elements of the array, for some integer .
Input
The first line contains an integer () — the number of test cases.
The first line of each test case contains one integer () — the size of the array .
The second line of each test case contains integers, (). It is guaranteed that all are distinct.
It is guaranteed that the sum of over all test cases does not exceed .
Output
For each test case, output a binary string of length — the -th character should be if there exists a sequence of operations as described above, and otherwise.
Note
In the first sample, you can first choose the prefix of size . Then the array is transformed into
| 1 | 4 | 7 | 2 |
|---|
Next, you can choose the suffix of size . Then the array is transformed into
| 1 | 4 | 7 |
|---|
Finally, you can choose the prefix of size . Then the array is transformed into
| 1 |
|---|
So we see that it is possible to transform into .
It can be shown that it is impossible to transform into .
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
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |