Advertisement
Saleh127

CF 451B

Oct 9th, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. ll a[200005],c[200005];
  6. int main()
  7. {
  8. ios_base::sync_with_stdio(0);
  9. cin.tie(0);cout.tie(0);
  10.  
  11. ll d,e,f,i,j,k,l;
  12.  
  13. cin>>d;
  14. j=k=l=0;
  15. for(i=0;i<d;i++)
  16. {
  17. cin>>a[i];
  18. c[i]=a[i];
  19. }
  20. sort(c,c+d);
  21. for(i=0;i<d;i++)
  22. {
  23. if(a[i]!=c[i])
  24. {
  25. l++;
  26. k=i;
  27. if(l==1)
  28. {
  29. j=i;
  30. }
  31. }
  32. }
  33. reverse(a+j,a+k+1);
  34. for(i=0;i<d;i++)
  35. {
  36. if(a[i]!=c[i])
  37. {
  38. cout<<"no"<<endl;
  39. return 0;
  40. }
  41. }
  42. cout<<"yes\n"<<j+1<<" "<<k+1<<endl;
  43. return 0;
  44. }
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement