AROPE - Alphabetic Rope
The Alphabetic Rope is now available in the market. The Alphabetic Rope consists of alphabetic
characters in each stripe which looks like string.
You are given an Alphabetic rope consists of lowercase alphabetic characters only,you have to perform
some operations on rope and answers some queries on it.
Queries are of 3 types:
- 1 X Y : Cut the rope segment from X to Y and join at the front of rope.
- 2 X Y : Cut the rope segment from X to Y and join at the back of rope.
- 3 Y: Print on a new line the Alphabet on Yth position of current rope.
There is only one input. Input begins with single line giving Alphabetic Rope as a string -S.
Next line containg Q, follows Q lines giving Queries as mentioned above. ( Index used are
For each query of type 3, Print a single character in a new line.
2 0 5
Easy question if you know a data structure(I used Treap) that can handle dynamic position changes.
"#include <ext/rope>" built-in rope data structure can be used in C++ to solve this problem.
Note that ranges are inclusive, i.e., 1 X Y describes a range [X..Y].
pretty easy with "known" STL
what's the problem in this code!
GETTING NZEC ERROR !!Last edit: 2016-12-16 18:25:27
TLE with fast i/o in java :/
♥☻♥ David ♥☻♥:
Time limit for C# language should be relaxed a bit to get AC.