#P4658. A Simple Task

    ID: 2225 传统题 5000ms 512MiB 尝试: 0 已通过: 0 难度: (无) 上传者: 标签>数据结构线段树基础算法排序CodeForces

A Simple Task

A Simple Task

题面翻译

题目大意: 给定一个长度不超过10^5的字符串(小写英文字母),和不超过50000个操作。

每个操作 L R K 表示给区间[L,R]的字符串排序,K=1为升序,K=0为降序。

最后输出最终的字符串。

题目描述

This task is very simple. Given a string S S of length n n and q q queries each query is on the format i i j j k k which means sort the substring consisting of the characters from i i to j j in non-decreasing order if k=1 k=1 or in non-increasing order if k=0 k=0 .

Output the final string after applying the queries.

输入格式

The first line will contain two integers n,q n,q ( 1<=n<=105 1<=n<=10^{5} , 0<=q<=50000 0<=q<=50000 ), the length of the string and the number of queries respectively.

Next line contains a string S S itself. It contains only lowercase English letters.

Next q q lines will contain three integers each i,j,k i,j,k ( 1<=i<=j<=n 1<=i<=j<=n , ).

输出格式

Output one line, the string S S after applying the queries.

样例 #1

样例输入 #1

10 5
abacdabcda
7 10 0
5 8 1
1 4 0
3 6 0
7 10 1

样例输出 #1

cbcaaaabdd

样例 #2

样例输入 #2

10 1
agjucbvdfk
1 10 1

样例输出 #2

abcdfgjkuv

提示

First sample test explanation: