欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1862C.Flower City Fence
Flower City Fence
Anya lives in the Flower City. By order of the city mayor, she has to build a fence for herself.
The fence consists of planks, each with a height of meters. According to the order, the heights of the planks must not increase. In other words, it is true that for all .
Anya became curious whether her fence is symmetrical with respect to the diagonal. In other words, will she get the same fence if she lays all the planks horizontally in the same order.
For example, for , , the fence is symmetrical. Because if all the planks are laid horizontally, the fence will be , as shown in the diagram.

On the left is the fence , on the right is the same fence laid horizontally
But for , , the fence is not symmetrical. Because if all the planks are laid horizontally, the fence will be , as shown in the diagram.

On the left is the fence , on the right is the same fence laid horizontally
Help Anya and determine whether her fence is symmetrical.
Input
The first line of the input contains an integer () — the number of test cases.
The description of the test cases follows.
The first line of a test case contains a single integer () — the length of the fence.
The second line of a test case contains integers () — the heights of the planks.
The sum of the values of for all test cases does not exceed .
Output
For each test case, output "YES" if the fence is symmetrical, otherwise output "NO".
You can output each letter in any case (lowercase or uppercase). For example, the strings "yEs", "yes", "Yes" and "YES" will be accepted as a positive answer.
Note
In the first and second test cases of the example, the fence is symmetrical.
In the third test case of the example, the fence is not symmetrical. If the planks are laid horizontally, the fence will be .
In the fourth test case of the example, the fence is not symmetrical. If the planks are laid horizontally, the fence will be .
In the fifth and sixth test cases of the example, the fence is symmetrical.
In the seventh test case of the example, the fence is not symmetrical. If the planks are laid horizontally, the fence will be .
Samples
7
5
5 4 3 2 1
3
3 1 1
3
4 2 1
1
2
5
5 3 3 1 1
5
5 5 5 3 3
2
6 1
YES
YES
NO
NO
YES
YES
NO
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |