| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 | 1024 MB | 63 | 16 | 13 | 24.074% |
In this problem, all strings are one-based indexed. Let $s_i$ be the $i$th character of a string $s$. Let $s_{l..r}$ be a substring of $s$ with the characters $s_ls_{l+1} \cdots s_r$.
You are given three strings each of length $N$: $A$, $B$, and $C$. You are asked to simulate $Q$ queries according to the given order.
For each query, you are given two integers $l$ and $r$ as parameters, and must performs the following procedures:
Determine the value of $A$, $B$, and $C$ after all queries.
Input begins with two integers $N$ $Q$ ($1 ≤ N ≤ 100\, 000$; $1 ≤ Q ≤ 100\, 000$) representing the length of the given strings and the number of queries. Each of the next $3$ lines contains a string of length $N$. The first, second, and third lines contain $A$, $B$, and $C$ respectively. The strings consist of lowercase characters. Each of the next Q lines contains two integers $l$ $r$ ($1 ≤ l ≤ r ≤ N$) representing the parameters of each query.
The output consists of $3$ lines. In each line, output the final value of $A$, $B$ and $C$ after all queries in that order.
5 2 icpca siaja karta 2 4 1 5
iarta kiaja scpca
In the first query, the value of $x$, $y$, and $z$ are cpc, iaj, art respectively. After sorting those strings, the value of $x'$, $y'$, and $z'$ becomes art, cpc, iaj. At the end of first query, the value of $A$, $B$, and $C$ are iarta, scpca and kiaja.
During the second query, the value of $x$, $y$, and $z$ are iarta, scpca, kiaja respectively. After sorting those strings, the value of $x'$, $y'$, and $z'$ becomes iarta, scpca, kiaja. At the end of second query, the value of $A$, $B$, and $C$ are iarta, kiaja and scpca.
Therefore the final value of $A$, $B$, $C$ are iarta, kiaja and scpca respectively.
6 6 aabbcc bcacab cbcaba 1 1 2 2 3 3 4 4 5 5 6 6
aaaaaa bbbbbb cccccc
3 1 aba aab aac 1 3
aab aac aba