report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
String sorting - MarisaOJ: Marisa Online Judge

String sorting

Time limit: 3000 ms
Memory limit: 256 MB
Given a string $S$ of length $n$ consisting of lowercase letters, there are $q$ queries of the form $(l, r, k)$. If $k$ is equal to $1$, sort the substring $S[l...r]$ in non-decreasing order; otherwise, if $k$ is equal to $0$, sort it in non-increasing order. ### Input - The first line contains two integers $n, q$. - The second line contains the string $S$. - The next $q$ lines each contain three integers $l, r, k$. ### Output - Print the string $S$ after performing the $q$ queries. ### Constraints - $1 \le n \le 10^5$, $1 \le q \le 5 \times 10^4$. ### Example Input: ``` 7 4 pmyyrgz 2 5 1 4 5 0 5 6 1 2 4 1 ``` Output: ``` pmrygyz ```
Introduction to Segment Tree and Binary Indexed Tree
Point update, sum query
Point update, minimum query
Range update, sum query
Range update, minimum query
Apple picking
Non-negative subarray
Inversions
K-query
Divisible by 3
Mushroom harvesting
KSS
D-query
Greatest subarray sum
Copying data
Within 1
Within 2
Ladder update
Racing
One time
Subarray XOR
String sorting
Odd query
Full sequence
Topic
Data structure
Rating 1900
Solution (0) Solution