Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int n,q,t,l,r,i,j,k;
- int main()
- {
- cin>>n;
- vector<int>a(n);
- for(i=0;i<n;i++)
- {
- cin>>a[i];
- }
- cin>>q;
- for(j=0;j<q;j++)
- {
- cin>>t>>l>>r;
- if(t==1)
- {
- reverse(a.begin()+l-1,a.begin()+r);
- vector <int> :: iterator it;
- for (it = a.begin(); it != a.end(); it++)
- {
- cout << (*it) << " ";
- }
- cout<<endl;
- }
- else if(t==2)
- {
- sort(a.begin()+l-1,a.begin()+r);
- vector <int> :: iterator it;
- for (it = a.begin(); it != a.end(); it++)
- {
- cout << (*it) << " ";
- }
- cout<<endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment