301347: CF252B. Unsorting Array
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Unsorting Array
题意翻译
现在有n个数,问是否可以交换两个不相同的数,使得这个数列不呈递增或递减(简单来说是没有排序),不行则输出-1,可以请输出交换哪两个数所在位置题目描述
Little Petya likes arrays of integers a lot. Recently his mother has presented him one such array consisting of $ n $ elements. Petya is now wondering whether he can swap any two distinct integers in the array so that the array got unsorted. Please note that Petya can not swap equal integers even if they are in distinct positions in the array. Also note that Petya must swap some two integers even if the original array meets all requirements. Array $ a $ (the array elements are indexed from 1) consisting of $ n $ elements is called sorted if it meets at least one of the following two conditions: 1. $ a_{1}<=a_{2}<=...<=a_{n} $ ; 2. $ a_{1}>=a_{2}>=...>=a_{n} $ . Help Petya find the two required positions to swap or else say that they do not exist.输入输出格式
输入格式
The first line contains a single integer $ n $ ( $ 1<=n<=10^{5} $ ). The second line contains $ n $ non-negative space-separated integers $ a_{1},a_{2},...,a_{n} $ — the elements of the array that Petya's mother presented him. All integers in the input do not exceed $ 10^{9} $ .
输出格式
If there is a pair of positions that make the array unsorted if swapped, then print the numbers of these positions separated by a space. If there are several pairs of positions, print any of them. If such pair does not exist, print -1. The positions in the array are numbered with integers from $ 1 $ to $ n $ .
输入输出样例
输入样例 #1
1
1
输出样例 #1
-1
输入样例 #2
2
1 2
输出样例 #2
-1
输入样例 #3
4
1 2 3 4
输出样例 #3
1 2
输入样例 #4
3
1 1 1
输出样例 #4
-1