#K7661. Swap to Sort Sequence
Swap to Sort Sequence
Swap to Sort Sequence
You are given a sequence of n integers. Your task is to determine if it is possible to make the sequence strictly increasing by swapping exactly two elements. The sequence is strictly increasing if every element is smaller than its following element. Formally, a sequence \(a_1, a_2, \dots, a_n\) is strictly increasing if \(a_1 < a_2 < \dots < a_n\).
If such a swap exists, output the 1-indexed positions of the two elements that need to be swapped. If the sequence is already strictly increasing or no single swap can sort the sequence into a strictly increasing order, output -1.
Note: If there are multiple possible answers, output the first one found according to the order of checking.
inputFormat
The first line contains an integer n representing the number of elements in the sequence.
The second line contains n space-separated integers representing the sequence.
outputFormat
If it is possible to make the sequence strictly increasing by performing exactly one swap, output two space-separated integers representing the (1-indexed) positions of the two elements. Otherwise, output -1.
## sample5
1 5 3 4 2
2 5