This post is all about the solution of the "A. Indirect Sort" CodeTON Round 3 (Div. 1 + Div. 2, Rated, Prizes!) Problem Solution.
Problem Statement :
You have been given a possible combination of size n, a1,a2,...,an, in which each integer from 1 to n appears precisely at first when.
Users can repeat the following operation an unlimited amount of times (possibly nil):
Select have a 3 indices i,j,k (1ijkn).
Try replacing ai with ai+aj if ai>ak. Alternately, switching aj and ak.
Ascertain whether the array can be sorted in non-descending sequence.
Format of Input :
Evey test is made up of several test cases. The very first line includes a single integer t (1t5000) indicating the number of test cases. The following is an overview of the tests.
Evey test case starts with a single integer n (3n10) — the length of the array a.
The second sentence includes n integer value a1,a2,...,an (1ain, aiaj if ij) — the array an aspects.
The total amount of n over in all test cases is assured not to surpass 5104.
Format of the Output :
For each test case print output as yes or no
0 Comments