fork download
  1. #include <iostream>
  2. using namespace std;
  3. int n,m,x;
  4.  
  5. int main() {
  6. cin >> n >> m;
  7. if (n==1){
  8. cout << -1;
  9. return 0;
  10. }
  11. int lista[n+1];
  12. lista[1] = n;
  13. for(int i=2; i<=n; i++){
  14. lista[i] = i-1;
  15. }
  16. for(int j=1; j<=m; j++){
  17. x = lista[1];
  18. lista[1] = lista[n-(j-1)];
  19. lista[n-(j-1)] = x;
  20. }
  21. for(int i=1; i<=n; i++){
  22. cout << lista[i] << " ";
  23. }
  24. return 0;
  25. }
Success #stdin #stdout 0s 15232KB
stdin
1 1
stdout
-1