Advertisement
osipyonok

rope example

Apr 28th, 2017
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.17 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #include <ext/rope>
  3.  
  4. #define INF 1000010000
  5. #define nl '\n'
  6. #define pb push_back
  7. #define ppb pop_back
  8. #define mp make_pair
  9. #define fi first
  10. #define se second
  11. #define pii pair<int,int>
  12. #define pdd pair<double,double>
  13. #define all(c) (c).begin(), (c).end()
  14. #define SORT(c) sort(all(c))
  15. #define sz(c) (c).size()
  16. #define rep(i,n) for( int i = 0; i < n; ++i )
  17. #define repi(i,n) for( int i = 1 ; i <= n; ++i )
  18. #define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
  19. #define repf(j,i,n) for( int j = i ; j < n ; ++j )
  20. #define die(s) {std::cout << s << nl;}
  21. #define dier(s) {std::cout << s; return 0;}
  22. #define vi vector<int>
  23. typedef long long ll;
  24.  
  25. using namespace std;
  26. using namespace __gnu_cxx;
  27.  
  28.  
  29. int main() {
  30.     ios_base::sync_with_stdio(false);
  31.     cin.tie(NULL);
  32.     cout.precision(0);
  33.  
  34.     int n , q;
  35.  
  36.     cin >> n >> q;
  37.  
  38.     rope<int> v(n , 0);
  39.  
  40.     rep(i , n){
  41.         v.mutable_reference_at(i) = i + 1;
  42.     }
  43.  
  44.     rep(i , q){
  45.         int l , r;
  46.         cin >> l >> r;
  47.         --l;
  48.         --r;
  49.         rope<int> cur = v.substr(l , r - l + 1);
  50.         v.erase(l , r - l + 1);
  51.         v.insert(v.mutable_begin() , cur);
  52.     }
  53.  
  54.     rep(i , n){
  55.         cout << v[i] << " ";
  56.     }
  57.  
  58.  
  59.     return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement