No.3317 Waronganswerronganswernswaronger
タグ : / 解いたユーザー数 31
作問者 :
ゆにたりー卿
Rice_tawara459
DeltaStruct
kazuppa
Andrew8128
のらら
👑 Problem Statement
An alien from Planet Iwai smuggled a string $S$ of length $N$ consisting of lowercase English letters from Earth to Planet Iwai.
However, on Planet Iwai, there is a property that every $1$ second, "each w in a string is replaced with warong, and each a is replaced with answer", so the smuggled string $S$ covered Planet Iwai in no time.
Here, it is known that the $1$st replacement of the smuggled string $S$ occurred exactly $1$ second after the string $S$ was brought to Planet Iwai.
Judging that the situation is already out of control, you decided to process the following $Q$ queries in order to simulate the impact on Planet Iwai.
For the $i$-th query, answer the following question correctly.
What is the $X_i$-th character of $S$ at $(T_i + 0.1)$ seconds after the string $S$ was brought to Planet Iwai (that is, immediately after the $T_i$-th replacement)?
Constraints
- $1 \leq N \leq 10^5$
- $1 \leq Q \leq 10^5$
- $1 \leq T_i \leq 10^{18}$
- $1 \leq X_i \leq 10^{18}$
- $N,\ Q,\ T_i,\ X_i \ (1 \leq i \leq Q)$ are all integers.
- The given string $S$ is the string at the time it was brought to Planet Iwai.
- The given string $S$ is a string of length $N$ consisting of lowercase English letters.
- The given string $S$ contains at least $1$
wora. - The length of $S$ at $(T_i + 0.1)$ seconds after the string $S$ was brought to Planet Iwai is at least $X_i$ characters $(1 \leq i \leq Q)$.
Input
Input is given from standard input in the following format.$N$ $Q$ $S$ $T_1$ $X_1$ $T_2$ $X_2$ $\vdots$ $T_Q$ $X_Q$
Output
Answer the $Q$ queries in the given order, and print the results as a string of $Q$ characters on $1$ line.
The $i$-th character must be the answer to the $i$-th query.
Sample
Sample 1
Input
2 3 wa 1 1 1 10 2 25
Output
www
The string $S$ changes as follows:
wa → waronganswer → waronganswerronganswernswaronger → ...
- The $1$st character of
waronganswerisw. - The $10$th character of
waronganswerisw. - The $25$th character of
waronganswerronganswernswarongerisw.
Note that different queries may have the same answer.
Sample 2
Input
8 8 chokudai 8 17 7 641 6 6 5 1 4 78 3 6 2 21 1 12
Output
redcoder
The given string $S$ may contain only one of w and a.
The queries are not necessarily given in ascending order of $T_i$ or of $X_i$.
The string $S$ changes as follows: chokudai → chokudansweri → chokudanswernswarongeri → ...
- The $17$th character of $S$ at $8.1$ seconds after it was brought to Planet Iwai is
r. - The $641$st character of $S$ at $7.1$ seconds after it was brought to Planet Iwai is
e. - The $6$th character of $S$ at $6.1$ seconds after it was brought to Planet Iwai is
d. - The $1$st character of $S$ at $5.1$ seconds after it was brought to Planet Iwai is
c. - The $78$th character of $S$ at $4.1$ seconds after it was brought to Planet Iwai is
o. - The $6$th character of $S$ at $3.1$ seconds after it was brought to Planet Iwai is
d. - The $21$st character of $S$ at $2.1$ seconds after it was brought to Planet Iwai is
e. - The $12$th character of $S$ at $1.1$ seconds after it was brought to Planet Iwai is
r.
Note that the order in which the queries must be answered is specified.
Also, the answers to queries $1,2,7,8$ are characters not contained in the string chokudai.
Be careful of such cases, where the answer is a character not in the given string $S$.
Sample 3
Input
5 5 yiwiy 1000000000000000000 999999999999999992 1000000000000000000 999999999999999999 1000000000000000000 999999999999999993 1000000000000000000 999999999999999993 1000000000000000000 999999999999999995
Output
green
No matter how many seconds pass, c never appears in $S$, so the string to be printed can never be cyan.
The string $S$ changes as follows: yiwiy → yiwarongiy → yiwaronganswerrongiy → yiwaronganswerronganswernswarongerrongiy → ...
- The $(10^{18} - 8)$-th character of $S$ at $(10^{18} + 0.1)$ seconds after it was brought to Planet Iwai is
g. - The $(10^{18} - 1)$-th character of $S$ at $(10^{18} + 0.1)$ seconds after it was brought to Planet Iwai is
r. - The $(10^{18} - 7)$-th character of $S$ at $(10^{18} + 0.1)$ seconds after it was brought to Planet Iwai is
e. - The $(10^{18} - 7)$-th character of $S$ at $(10^{18} + 0.1)$ seconds after it was brought to Planet Iwai is
e. - The $(10^{18} - 5)$-th character of $S$ at $(10^{18} + 0.1)$ seconds after it was brought to Planet Iwai is
n.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。