SHARE
TWEET

2 C

kot_mapku3 Jun 2nd, 2020 457 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. void reverse(vector<long long>& v, int l, int r){
  7.     while (l < r) {
  8.         swap(v[l-1], v[r-1]);
  9.         l++;
  10.         r--;
  11.     }
  12. }
  13.  
  14. int main(){
  15.     ios::sync_with_stdio(false);
  16.     cin.tie(nullptr);
  17.  
  18.     int n;
  19.     cin >> n;
  20.     vector<long long> v(n);
  21.     for (int i = 0; i < n; ++i) {
  22.         cin >> v[i];
  23.     }
  24.  
  25.     int l, r;
  26.     cin >> l >> r;
  27.     while (l != 0 && r != 0){
  28.         reverse(v, l, r);
  29.         cin >> l >> r;
  30.     }
  31.  
  32.     for (int j = 0; j < (int)v.size(); ++j) {
  33.         cout << v[j] << " ";
  34.     }
  35.  
  36.     return 0;
  37. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top