uva11922 (forcibly replaced with rope spaly)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.