CF558E.A Simple Task

提高+/省选-

通过率:0%

时间限制:5.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

本题非常简单。给定一个长度为 nn 的字符串 SS,以及 qq 个查询,每个查询的格式为 ii jj kk,表示:若 k=1k = 1,则将 SS 中从第 ii 个字符到第 jj 个字符(包含端点)组成的子串按非递减顺序排序;若 k=0k = 0,则按非递增顺序排序。

请输出执行完所有查询后的最终字符串。

输入格式

The first line will contain two integers n, q (1 ≤ n ≤ 105, 0 ≤ q ≤ 50 000), 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, ).

第一行包含两个整数 nn 和 qq(1≤n≤1051 \leq n \leq 10^5,0≤q≤50 0000 \leq q \leq 50\,000),分别表示字符串的长度和查询次数。

下一行包含字符串 SS 本身,其中仅包含小写英文字母。

接下来的 qq 行每行包含三个整数 ii、jj、kk(1≤i≤j≤n1 \leq i \leq j \leq n,)。

输出格式

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

输出一行,即对字符串 SS 执行所有查询操作后的结果字符串。

输入输出样例

  • 输入#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:

第一个样例测试解释:

输入解题思路,AI测评打分。不知道怎么写?

首页