C. Element Extermination
C. Element Extermination
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
You are given an array aa of length nn, which initially is a permutation of numbers from 11 to nn. In one operation, you can choose an index ii (1≤i For example, if you have the array [1,3,2][1,3,2], you can choose i=1i=1 (since a1=1 Is it possible to make the length of this array equal to 11 with these operations? Input The first line contains a single integer tt (1≤t≤2⋅1041≤t≤2⋅104) — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer nn (2≤n≤3⋅1052≤n≤3⋅105) — the length of the array. The second line of each test case contains nn integers a1a1, a2a2, ..., anan (1≤ai≤n1≤ai≤n, aiai are pairwise distinct) — elements of the array. It is guaranteed that the sum of nn over all test cases doesn't exceed 3⋅1053⋅105. Output For each test case, output on a single line the word "YES" if it is possible to reduce the array to a single element using the aforementioned operation, or "NO" if it is impossible to do so. Example input Copy output Copy Note For the first two test cases and the fourth test case, we can operate as follow (the bolded elements are the pair chosen for that operation): [1,2,3]→[1,2]→[1][1,2,3]→[1,2]→[1] [3,1,2,4]→[3,1,4]→[3,4]→[4][3,1,2,4]→[3,1,4]→[3,4]→[4] [2,4,6,1,3,5]→[4,6,1,3,5]→[4,1,3,5]→[4,1,5]→[4,5]→[4][2,4,6,1,3,5]→[4,6,1,3,5]→[4,1,3,5]→[4,1,5]→[4,5]→[4] ========================================================================= 这种问题,下下策是用一天时间妄图用算法高级数据结构去解,下策是用半天模拟,中策是半小时证明,上策是写4的全部排列五分钟找出来规律
4
3
1 2 3
4
3 1 2 4
3
2 3 1
6
2 4 6 1 3 5
YES
YES
NO
YES
office的excel中使用,告诉我详细的解决方案,如何变成转化为金额格式
“基础不牢地动山摇“ ==> 重温 《内部类》
MongoDB入门与实战-第四章-SpringBoot集成MongoDB
轻量级神经网络算法-MobileNet v1
Flask--登录页面应用案例
淘宝图片搜索API / item_search_img-按图搜索淘宝商品(拍立淘)/图片搜索API调用值说明
电子招标采购系统源码Spring Cloud + Spring Boot + MybatisPlus + 前后端分离 + 二次开发
[AIGC] 自定义Spring Boot中BigDecimal的序列化方式
【外汇天眼】解析外汇交易平台:深度了解DD与NDD两大模式