fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define int long long
  5. #define sz(x) x.size()
  6. #define all(v) v.begin(), v.end()
  7. #define allr(v) v.rbegin(), v.rend()
  8. #define F first
  9. #define S second
  10.  
  11. void solve()
  12. {
  13. int n; cin >> n;
  14. vector<int> a(n);
  15. for (auto &it : a) cin >> it;
  16. vector<int> b = a;
  17. sort(all(b));
  18. int l = -1, r = -1;
  19. for (int i = 0; i < n; ++i)
  20. {
  21. if (a[i] != b[i])
  22. {
  23. l = i;
  24. break;
  25. }
  26. }
  27. if (l == -1)
  28. return void (cout << "yes\n1 1");
  29. for (int i = n - 1; i >= 0; --i)
  30. {
  31. if (a[i] != b[i])
  32. {
  33. r = i;
  34. break;
  35. }
  36. }
  37. reverse(a.begin() + l, a.begin() + r + 1);
  38. if (a == b)
  39. cout << "yes\n" << ++l << ' ' << ++r;
  40. else
  41. cout << "no";
  42. }
  43.  
  44. signed main()
  45. {
  46. ios_base::sync_with_stdio(false), cin.tie(nullptr);
  47. int tc = 1;
  48. // cin >> tc;
  49. while (tc--)
  50. {
  51. solve();
  52. if (tc)
  53. cout << '\n';
  54. }
  55. return 0;
  56. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
yes
1 1