321
社区成员




已知存在一个长度为n的整数序列A。 A中所有元素按照从小到达的顺序进行排序。 现在执行操作倒置一段序列。 请找到A序列里的倒置子序列。
输出被倒置的数列的左值,右值。 如果没有输出0 0
哦哦,有特例零啊
n = int(input())
arr = list(map(int,input().split()))
p,q = -1,n
for i in range(1,n):
if arr[i] < arr[i - 1] and p < 0:
p = i - 1
if p >= 0 and arr[i] > arr[i - 1]:
q = i - 1
break
print(p + 1,q + 1 if q != n else 0)