Saleh127

aurup

Jun 11th, 2020
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int n,q,t,l,r,i,j,k;
  4. int main()
  5. {
  6. cin>>n;
  7. vector<int>a(n);
  8. for(i=0;i<n;i++)
  9. {
  10. cin>>a[i];
  11. }
  12. cin>>q;
  13. for(j=0;j<q;j++)
  14. {
  15. cin>>t>>l>>r;
  16. if(t==1)
  17. {
  18. reverse(a.begin()+l-1,a.begin()+r);
  19. vector <int> :: iterator it;
  20. for (it = a.begin(); it != a.end(); it++)
  21. {
  22. cout << (*it) << " ";
  23. }
  24. cout<<endl;
  25. }
  26. else if(t==2)
  27. {
  28. sort(a.begin()+l-1,a.begin()+r);
  29. vector <int> :: iterator it;
  30. for (it = a.begin(); it != a.end(); it++)
  31. {
  32. cout << (*it) << " ";
  33. }
  34. cout<<endl;
  35. }
  36. }
  37. return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment