Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- void reverse(vector<long long>& v, int l, int r){
- while (l < r) {
- swap(v[l-1], v[r-1]);
- l++;
- r--;
- }
- }
- int main(){
- ios::sync_with_stdio(false);
- cin.tie(nullptr);
- int n;
- cin >> n;
- vector<long long> v(n);
- for (int i = 0; i < n; ++i) {
- cin >> v[i];
- }
- int l, r;
- cin >> l >> r;
- while (l != 0 && r != 0){
- reverse(v, l, r);
- cin >> l >> r;
- }
- for (int j = 0; j < (int)v.size(); ++j) {
- cout << v[j] << " ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement