测评会员优惠活动进行中 · 开通 VIP,有效期内测评不限次 VIP 优惠中 · 测评不限次 立即查看

A9881. A Simple Task

编程题 普及/提高-

题目描述

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

Output the final string after applying the queries.
这项任务非常简单。给定长度为 n 的字符串 S 和 q 查询,每个查询的格式为 i j k 这意味着,如果是 k = 1 ,则对由 i 至 j 字符组成的子串进行非递减排序;如果是 k = 0 ,则对由 i 至 j 字符组成的子串进行非递增排序。

应用查询后输出最终字符串。

输入格式

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

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

Next $q$ lines will contain three integers each $i,j,k$ ( $1<=i<=j<=n$ , ![](/uploads/acgo/image/ce6c389c02e5071a_94949c4338b4.jpeg)).
输入
第一行将包含两个整数 $n,q$ ( $1<=n<=10^{5}$ , $0<=q<=50000$ ),分别是字符串长度和查询次数。
下一行包含一个字符串 S 。它只包含小写英文字母。

接下来的 q 行将分别包含三个整数$i,j,k$ ( $1<=i<=j<=n$ , ![](/uploads/acgo/image/ce6c389c02e5071a_94949c4338b4.jpeg)).

输出格式

Output one line, the string $S$ after applying the queries.
输出
应用查询后输出一行字符串 S 。

输入输出样例

输入 #1
10 5
abacdabcda
7 10 0
5 8 1
1 4 0
3 6 0
7 10 1
输出 #1
cbcaaaabdd
输入 #2
10 1
agjucbvdfk
1 10 1
输出 #2
abcdfgjkuv

说明/提示

First sample test explanation:
第一个样本测试说明:

![](/uploads/acgo/image/2adec41a1a183af8_21b651ca2497.jpeg)

![](/uploads/acgo/image/15bf2d8877e689e1_e5a0f0de721b.jpeg)

![](/uploads/acgo/image/133379c6ebc449e8_a5249b37e468.jpeg)

![](/uploads/acgo/image/aed7048ec5c67036_e326fd78debf.jpeg)

![](/uploads/acgo/image/d37b46cbe56d4032_1b76f15a87d4.jpeg)
上一题 去做题 下一题