Spaly did not learn, with rope water,
Rope is something in the extension library, codeblocks compiler support,
Need to include
#include <ext/rope>
using namespace __gnu_cxx;
The various operating times of the rope are log (n)
But do not provide the operation of flipping, then how to implement the flip it?
As long as the maintenance of a positive and a reverse of two rope,
Anti-rope is used when the rope is being flipped and updated
Reverse rope is used to rope when flipping updates.
The code is very short ....
1#include <iostream>2#include <string.h>3#include <stdio.h>4#include <time.h>5#include <algorithm>6#include <map>7#include <ext/rope>8 using namespace__gnu_cxx;9 using namespacestd;Tenrope<int>ro; Onerope<int>Revro; A intMain () - { - intn,m; thescanf"%d%d",&n,&m); - for(intI=1; i<=n;++i) - { - ro.append (i); + - } + for(inti=n;i>=1;--i) A { at revro.append (i); - } - intL,r; - while(m--) - { -scanf"%d%d",&l,&R); inL--, r--; -rope<int> tmp = RO.SUBSTR (l,r-l+1); torope<int> revtmp = Revro.substr (n-r-1, r-l+1); +Ro.erase (l,r-l+1); -Revro.erase (n-r-1, r-l+1); the ro.append (revtmp); *Revro = tmp +Revro; $ }Panax Notoginseng for(intI=0; i<n;++i) -printf"%d\n", Ro[i]); the +}
uva11922 (forcibly replaced with rope spaly)