欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1948B.Array Fix
Array Fix
You are given an integer array of length .
You can perform the following operation any number of times (possibly zero): take any element of the array , which is at least , delete it, and instead insert the digits that element consisted of in the same position, in order they appear in that element.
For example:
- if we apply this operation to the -rd element of the array , then the array becomes .
- if we apply this operation to the -nd element of the array , then the array becomes .
Your task is to determine whether it is possible to make sorted in non-descending order using the aforementioned operation any number of times (possibly zero). In other words, you have to determine if it is possible to transform the array in such a way that , where is the current length of the array .
Input
The first line contains a single integer () — the number of test cases.
Each test case consists of two lines:
- the first line contains a single integer ().
- the second line contains integers ().
Output
For each test case, print YES if it is possible to make sorted in non-decreasing order using the aforementioned operation; otherwise, print NO.
You can print each letter in any case. For example, yes, Yes, YeS will all be recognized as a positive answer.
Note
In the first example, you can split the first element, then the array becomes .
In the second example, there is no way to get a sorted array.
In the third example, the array is already sorted.
Samples
3
4
12 3 45 67
3
12 28 5
2
0 0
YES
NO
YES
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |