-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path25.cpp
More file actions
50 lines (40 loc) · 996 Bytes
/
25.cpp
File metadata and controls
50 lines (40 loc) · 996 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// O(n*log(n))
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <iomanip>
using namespace std;
#define FILE_IO {freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);}
#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(NULL), cout.tie(NULL)
int main() {
FAST_IO;
// FILE_IO;
int n, l = -1, r = -1; cin >> n;
int *a = new int[n], *sa = new int[n];
for (int i = 0; i < n; ++i) {
cin >> a[i];
sa[i] = a[i];
}
sort(sa, sa + n);
for (int i = 0; i < n; ++i) {
if (a[i] != sa[i]) {
if (l == -1) l = i;
r = i;
}
}
if (l != r)
for (int i = l, j = r; i <= r; ++i, --j) {
if (a[i] != sa[j]) {
cout << "no";
return 0;
}
}
if (l == -1 && r == -1) {
l = 0;
r = 0;
}
cout << "yes" << endl << l + 1 << " " << r + 1;
return 0;
}