fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. #define x 100000
  5.  
  6. int input[x]{};
  7. bool check[x]{};
  8.  
  9. int main()
  10. {
  11. unsigned int n;
  12. cin >> n;
  13. unsigned int count = 0;
  14.  
  15. for (int i = 0; i < n; ++i)
  16. {
  17. cin >> input[i];
  18. if (input[i] != (i + 1))
  19. {
  20. ++count;
  21. check[i] = 1;
  22. }
  23. }
  24.  
  25. if (count > 2)
  26. cout << "no\n";
  27.  
  28. else
  29. {
  30. cout << "yes\n";
  31.  
  32. if (count != 0)
  33. {
  34. for (int i = 0, refrence = 0; i < n && refrence != 2; ++i)
  35. {
  36. if (check[i])
  37. {
  38. cout << (i + 1) << ' ';
  39. ++refrence;
  40. }
  41. }
  42. }
  43.  
  44. else
  45. cout << 1 << ' ' << 1;
  46.  
  47. cout << '\n';
  48. }
  49. return 0;
  50. }
  51.  
  52.  
Success #stdin #stdout 0.01s 5296KB
stdin
Standard input is empty
stdout
no