首页 > 试题广场 >

String puzzle

[编程题]String puzzle
  • 热度指数:18 时间限制:C/C++ 5秒,其他语言10秒 空间限制:C/C++ 512M,其他语言1024M
  • 算法知识视频讲解
The boss of P company plays an interesting game with employees. At the beginning, the boss gives a very long string with length m. The boss invites n employees to reorder the string with command a, s, e, where a in {0, 1} denotes the type of operation, s and e are positions in the string. If a = 0, all characters from s to e are ordered in non-increasing order. If a = 1, all characters from s to e are ordered in non-decreasing order. After n times operation, the boss wants to know the final string.

输入描述:
The first line contains two integers m, (1 <= m <= 100000), n, (0 <= n <= 50000) - the length of the string and the number of operations. The next line contains a string with length m. Next n lines contain operation command a, s, e, where a in {0, 1} and 1 <= s <= e <= m.


输出描述:
One line contains the final string.
示例1

输入

10 3
naitdocexv
1 1 3
0 9 10
1 7 9
    

输出

aintdocexv
    

这道题你会答吗?花几分钟告诉大家答案吧!