-
Notifications
You must be signed in to change notification settings - Fork 54
/
451B. Sort the Array.cpp
67 lines (54 loc) · 943 Bytes
/
451B. Sort the Array.cpp
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
problem name: 451B. Sort the Array.
status:Tle
problem link:http://codeforces.com/contest/451/problem/B
author :mohand sakr.
*/
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
#include <iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
int n;
cin>>n;
vector<int> vect;
for(int i=0;i<n;i++){
int x;
cin>>x;
vect.push_back(x);
}
if(is_sorted(vect.begin(),vect.end()))
{
cout<<"yes\n";
cout<<"1 1\n";
}
else {
for(int i=0;i<=n;i++){
for(int j=0;j<=n;j++){
vector<int> vect2=vect;
if(i<j){
for(int i=0;i<=n;i++){
}
reverse(vect2.begin()+i,vect2.begin()+j);
if(is_sorted(vect2.begin(),vect2.end()))
{
cout<<"yes\n";
if(i<j){
cout<<++i<<" "<<j<<"\n";
}
else {
cout<<++j<<" "<<++i<<"\n";
}
return 0;
}
}
}
}
cout<<"no\n";
}
return 0;
}