問題一覧 > 通常問題

No.1471 Sort Queries

レベル : / AI推定難易度 : 450 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 226
作問者 : 蜜蜂 / テスター : Mitarushi nok0
お気に入りにしたユーザー ProblemId : 5563 / 自分の提出
問題文最終更新日: 2021-04-09 23:37:10
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 290 (順位表) の他の問題:

Problem Statement

You are given a string $S$ consisting of $N$ lowercase English letters.

Process $Q$ queries.

The $i$-th query is as follows.
Among the strings obtained by arbitrarily rearranging the substring of $S$ from the $L_i$-th character to the $R_i$-th character, take the lexicographically smallest one and print its $X_i$-th character.

Input

$N\ \ Q$
$S$
$L_1\ \ R_1\ \ X_1$
$L_2\ \ R_2\ \ X_2$
$\ \vdots$
$L_Q\ \ R_Q\ \ X_Q$

  • $S$ is a string of length $N$ consisting only of lowercase English letters
  • $ 1 \leq N,Q \leq 10^4$
  • $ 1 \leq L_i \leq R_i \leq N(1\leq i \leq Q)$
  • $ 1 \leq X_i \leq R_i-L_i+1(1\leq i \leq Q)$
  • All inputs other than $S$ are integers

Output

Print $Q$ lines. On the $i$-th line, print the answer to the $i$-th query, followed by a newline.

Sample

Sample 1
Input
5 3
query
2 4 2
1 5 3
3 3 1
Output
r
r
e

Consider the $1$-st query.

The substring of $S$ from the $2$-nd character to the $4$-th character is uer, and the lexicographically smallest among its rearrangements is eru.
Print its $2$-nd character, r.

Sample 2
Input
10 4
japanjapan
1 10 5
3 7 1
4 9 2
2 2 1
Output
j
a
a
a

Sample 3
Input
16 6
amazingmightyyyy
1 5 4
2 16 1
8 9 1
2 2 1
1 16 2
4 10 4
Output
m
a
i
m
a
i

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。