No.1471 Sort Queries
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もしくは右上の雲マークをクリックしてアカウントを作成してください。
蜜蜂
nok0