Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
末尾が er または ist であるような文字列 S が与えられます。
S の末尾が er である場合は er を、 ist である場合は ist を出力してください。
制約
- 2 \le |S| \le 20
- S は英小文字のみからなる。
- S の末尾は
erまたはistである。
入力
入力は以下の形式で標準入力から与えられる。
S
出力
答えを出力せよ。
入力例 1
atcoder
出力例 1
er
S="atcoder" の末尾は er です。
入力例 2
tourist
出力例 2
ist
入力例 3
er
出力例 3
er
Score : 100 points
Problem Statement
You are given a string S ending with er or ist.
If S ends with er, print er; if it ends with ist, print ist.
Constraints
- 2 \le |S| \le 20
- S consists of lowercase English letters.
- S ends with
erorist.
Input
Input is given from Standard Input in the following format:
S
Output
Print the answer.
Sample Input 1
atcoder
Sample Output 1
er
S="atcoder" ends with er.
Sample Input 2
tourist
Sample Output 2
ist
Sample Input 3
er
Sample Output 3
er
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
v と w のみからなる文字列 S が与えられます。
S の中に、下に尖っている部分が何箇所あるかを出力してください(入出力例にある図もご参照ください)。
制約
- S は
vとwのみからなる文字列 - S の長さは 1 以上 100 以下
入力
入力は以下の形式で標準入力から与えられる。
S
出力
答えを整数として出力せよ。
入力例 1
vvwvw
出力例 1
7

上の画像のように、vvwvw という文字列には下に尖った部分が 7 箇所あります。
入力例 2
v
出力例 2
1
入力例 3
wwwvvvvvv
出力例 3
12
Score : 100 points
Problem Statement
You are given a string S consisting of v and w.
Print the number of "bottoms" in the string S (see the figure at Sample Input/Output).
Constraints
- S is a string consisting of
vandw. - The length of S is between 1 and 100, inclusive.
Input
The input is given from Standard Input in the following format:
S
Output
Print the answer as an integer.
Sample Input 1
vvwvw
Sample Output 1
7

The image above shows the seven "bottoms" in the string vvwvw.
Sample Input 2
v
Sample Output 2
1
Sample Input 3
wwwvvvvvv
Sample Output 3
12
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
1 から N までの番号がついた N 人の人がいます。
N 人の人の今後 D 日間の予定が与えられます。人 i の予定は長さ D の文字列 S_i で表されて、S_i の j 文字目が o ならば j 日目は暇であることを、x ならばそうでないことを意味します。
D 日間のうち全員が暇であるような 連続する 何日かを選ぶことを考えます。
選べる日数は最大で何日ですか?ただし、選べる日が存在しない場合は 0 日と答えてください。
制約
- 1 \leq N \leq 100
- 1 \leq D \leq 100
- N, D は整数
- S_i は
oとxからなる長さ D の文字列
入力
入力は以下の形式で標準入力から与えられる。
N D S_1 S_2 \vdots S_N
出力
選べる日数の最大値を出力せよ。選べる日が存在しない場合は 0 を出力せよ。
入力例 1
3 5 xooox oooxx oooxo
出力例 1
2
2 日目と 3 日目は全員が暇な日なので選ぶことができます。
この 2 日間を選ぶと、連続する日にちを選ぶ方法の中で日数を最大にすることができます。
入力例 2
3 3 oxo oxo oxo
出力例 2
1
選ぶ日にちは連続している必要があるのに注意してください。(1 日目と 3 日目は全員が暇な日なので選ぶことができますが、この 2 つを同時に選ぶことはできません)
入力例 3
3 3 oox oxo xoo
出力例 3
0
選べる日が存在しない場合は 0 を出力してください。
入力例 4
1 7 ooooooo
出力例 4
7
入力例 5
5 15 oxooooooooooooo oxooxooooooooox oxoooooooooooox oxxxooooooxooox oxooooooooxooox
出力例 5
5
Score : 200 points
Problem Statement
There are N people numbered 1 to N.
You are given their schedule for the following D days. The schedule for person i is represented by a string S_i of length D. If the j-th character of S_i is o, person i is free on the j-th day; if it is x, they are occupied that day.
From these D days, consider choosing some consecutive days when all the people are free.
How many days can be chosen at most? If no day can be chosen, report 0.
Constraints
- 1 \leq N \leq 100
- 1 \leq D \leq 100
- N and D are integers.
- S_i is a string of length D consisting of
oandx.
Input
The input is given from Standard Input in the following format:
N D S_1 S_2 \vdots S_N
Output
Print the maximum number of days that can be chosen, or 0 if no day can be chosen.
Sample Input 1
3 5 xooox oooxx oooxo
Sample Output 1
2
All the people are free on the second and third days, so we can choose them.
Choosing these two days will maximize the number of days among all possible choices.
Sample Input 2
3 3 oxo oxo oxo
Sample Output 2
1
Note that the chosen days must be consecutive. (All the people are free on the first and third days, so we can choose either of them, but not both.)
Sample Input 3
3 3 oox oxo xoo
Sample Output 3
0
Print 0 if no day can be chosen.
Sample Input 4
1 7 ooooooo
Sample Output 4
7
Sample Input 5
5 15 oxooooooooooooo oxooxooooooooox oxoooooooooooox oxxxooooooxooox oxooooooooxooox
Sample Output 5
5
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
1 から N までの番号が付いた N 人のプレイヤーが総当たり戦をしました。この総当たり戦で行われた試合全てについて、二人の一方が勝ち、もう一方が負けました。
総当たり戦の結果は N 個の長さ N の文字列 S_1,S_2,\ldots,S_N によって以下の形式で与えられます。
-
i\neq j のとき、S_i の j 文字目は
o,xのいずれかであり、oのときプレイヤー i がプレイヤー j に勝ったことを、xのときプレイヤー i がプレイヤー j に負けたことを意味する。 -
i=j のとき、S_i の j 文字目は
-である。
総当たり戦で勝った試合数が多いほうが順位が上であり、勝った試合数が同じ場合は、プレイヤーの番号が小さいほうが順位が上となります。 N 人のプレイヤーの番号を順位が高い順に答えてください。
制約
- 2\leq N\leq 100
- N は整数
- S_i は
o,x,-からなる長さ N の文字列 - S_1,\ldots,S_N は問題文中の形式を満たす
入力
入力は以下の形式で標準入力から与えられる。
N S_1 S_2 \vdots S_N
出力
N 人のプレイヤーの番号を、順位が高い順に空白区切りで出力せよ。
入力例 1
3 -xx o-x oo-
出力例 1
3 2 1
プレイヤー 1 は 0 勝、プレイヤー 2 は 1 勝、プレイヤー 3 は 2 勝なので、プレイヤーの番号は順位が高い順に 3,2,1 です。
入力例 2
7 -oxoxox x-xxxox oo-xoox xoo-ooo ooxx-ox xxxxx-x oooxoo-
出力例 2
4 7 3 1 5 2 6
プレイヤー 4 とプレイヤー 7 はどちらも 5 勝ですが、プレイヤー番号が小さいプレイヤー 4 のほうが順位が上になります。
Score : 200 points
Problem Statement
There are N players numbered 1 to N, who have played a round-robin tournament. For every match in this tournament, one player won and the other lost.
The results of the matches are given as N strings S_1,S_2,\ldots,S_N of length N each, in the following format:
-
If i\neq j, the j-th character of S_i is
oorx.omeans that player i won against player j, andxmeans that player i lost to player j. -
If i=j, the j-th character of S_i is
-.
The player with more wins ranks higher. If two players have the same number of wins, the player with the smaller player number ranks higher. Report the player numbers of the N players in descending order of rank.
Constraints
- 2\leq N\leq 100
- N is an integer.
- S_i is a string of length N consisting of
o,x, and-. - S_1,\ldots,S_N conform to the format described in the problem statement.
Input
The input is given from Standard Input in the following format:
N S_1 S_2 \vdots S_N
Output
Print the player numbers of the N players in descending order of rank.
Sample Input 1
3 -xx o-x oo-
Sample Output 1
3 2 1
Player 1 has 0 wins, player 2 has 1 win, and player 3 has 2 wins. Thus, the player numbers in descending order of rank are 3,2,1.
Sample Input 2
7 -oxoxox x-xxxox oo-xoox xoo-ooo ooxx-ox xxxxx-x oooxoo-
Sample Output 2
4 7 3 1 5 2 6
Both players 4 and 7 have 5 wins, but player 4 ranks higher because their player number is smaller.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 300 点
問題文
長さ N の整数からなる数列 A=(A_1,\ldots,A_N),B=(B_1,\ldots,B_N) が与えられます。
以下の条件を全て満たす長さ N の数列 X=(X_1,\ldots,X_N) が存在するかを判定してください。
-
すべての i(1\leq i\leq N) について、X_i = A_i または X_i = B_i
-
すべての i(1\leq i\leq N-1) について、|X_i - X_{i+1}| \leq K
制約
- 1 \leq N \leq 2\times 10^5
- 0 \leq K \leq 10^9
- 1 \leq A_i,B_i \leq 10^9
- 入力は全て整数である
入力
入力は以下の形式で標準入力から与えられる。
N K A_1 \ldots A_N B_1 \ldots B_N
出力
条件を全て満たす X が存在するならば Yes と、存在しないならば No と出力せよ。
入力例 1
5 4 9 8 3 7 2 1 6 2 9 5
出力例 1
Yes
X=(9,6,3,7,5) が全ての条件を満たします。
入力例 2
4 90 1 1 1 100 1 2 3 100
出力例 2
No
条件を満たす X は存在しません。
入力例 3
4 1000000000 1 1 1000000000 1000000000 1 1000000000 1 1000000000
出力例 3
Yes
Score : 300 points
Problem Statement
You are given two sequences, each of length N, consisting of integers: A=(A_1, \ldots, A_N) and B=(B_1, \ldots, B_N).
Determine whether there is a sequence of length N, X=(X_1, \ldots, X_N), satisfying all of the conditions below.
-
X_i = A_i or X_i = B_i, for every i(1\leq i\leq N).
-
|X_i - X_{i+1}| \leq K, for every i(1\leq i\leq N-1).
Constraints
- 1 \leq N \leq 2\times 10^5
- 0 \leq K \leq 10^9
- 1 \leq A_i,B_i \leq 10^9
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K A_1 \ldots A_N B_1 \ldots B_N
Output
If there is an X that satisfies all of the conditions, print Yes; otherwise, print No.
Sample Input 1
5 4 9 8 3 7 2 1 6 2 9 5
Sample Output 1
Yes
X=(9,6,3,7,5) satisfies all conditions.
Sample Input 2
4 90 1 1 1 100 1 2 3 100
Sample Output 2
No
No X satisfies all conditions.
Sample Input 3
4 1000000000 1 1 1000000000 1000000000 1 1000000000 1 1000000000
Sample Output 3
Yes
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 300 点
問題文
3\times3 のマス目に 1 から 9 までの数字が書き込まれており、上から i 行目、左から j 列目 (1\leq i\leq3,1\leq j\leq3) に書き込まれている数字は c _ {i,j} です。
異なるマスに同じ数字が書き込まれている場合もありますが、同じ数字が縦・横・斜めに 3 つ連続して書き込まれていることはありません。 より厳密には、c _ {i,j} について次の条件のすべてが成り立っていることが保証されます。
- どの 1\leq i\leq3 についても、c _ {i,1}=c _ {i,2}=c _ {i,3} ではない
- どの 1\leq j\leq3 についても、c _ {1,j}=c _ {2,j}=c _ {3,j} ではない
- c _ {1,1}=c _ {2,2}=c _ {3,3} ではない
- c _ {3,1}=c _ {2,2}=c _ {1,3} ではない
高橋くんは、それぞれのマスに書かれている数字をランダムな順番で知ります。 高橋くんは、縦・横・斜めの列のうちの 1 つでも次の条件を満たしたときがっかりします。
- はじめに知ったほうの 2 マスに書かれた数字が同じであり、最後に知ったマスに書かれた数字がそれと異なる。
高橋くんががっかりせずにすべてのマスに書かれた数字を知る確率を求めてください。
制約
- c _ {i,j}\in\lbrace1,2,3,4,5,6,7,8,9\rbrace\ (1\leq i\leq3,1\leq j\leq3)
- c _ {i,1}=c _ {i,2}=c _ {i,3} ではない (1\leq i\leq3)
- c _ {1,j}=c _ {2,j}=c _ {3,j} ではない (1\leq j\leq3)
- c _ {1,1}=c _ {2,2}=c _ {3,3} ではない
- c _ {1,3}=c _ {2,2}=c _ {3,1} ではない
入力
入力は以下の形式で標準入力から与えられる。
c _ {1,1} c _ {1,2} c _ {1,3}
c _ {2,1} c _ {2,2} c _ {2,3}
c _ {3,1} c _ {3,2} c _ {3,3}
出力
高橋くんががっかりせずにすべてのマスに書かれた数字を知る確率を 1 行で出力せよ。 真の値からの絶対誤差が 10 ^ {-8} 以下であるとき、正答と判定される。
入力例 1
3 1 9 2 5 6 2 7 1
出力例 1
0.666666666666666666666666666667
例えば、高橋くんが c _ {3,1}=2,c _ {2,1}=2,c _ {1,1}=3 の順に知った場合、高橋くんはがっかりしてしまいます。

対して、高橋くんが c _ {1,1},c _ {1,2},c _ {1,3},c _ {2,1},c _ {2,2},c _ {2,3},c _ {3,1},c _ {3,2},c _ {3,3} の順に数字を知った場合、がっかりすることなくすべての数字を知ることができます。
高橋くんががっかりすることなくすべての数字を知ることができる確率は \dfrac 23 です。 絶対誤差が 10 ^ {-8} 以下であれば正答と判定されるため、0.666666657 や 0.666666676 のように出力しても正解になります。
入力例 2
7 7 6 8 6 8 7 7 6
出力例 2
0.004982363315696649029982363316
入力例 3
3 6 7 1 9 7 5 7 5
出力例 3
0.4
Score : 300 points
Problem Statement
There is a 3\times3 grid with numbers between 1 and 9, inclusive, written in each square. The square at the i-th row from the top and j-th column from the left (1\leq i\leq3,1\leq j\leq3) contains the number c _ {i,j}.
The same number may be written in different squares, but not in three consecutive cells vertically, horizontally, or diagonally. More precisely, it is guaranteed that c _ {i,j} satisfies all of the following conditions.
- c _ {i,1}=c _ {i,2}=c _ {i,3} does not hold for any 1\leq i\leq3.
- c _ {1,j}=c _ {2,j}=c _ {3,j} does not hold for any 1\leq j\leq3.
- c _ {1,1}=c _ {2,2}=c _ {3,3} does not hold.
- c _ {3,1}=c _ {2,2}=c _ {1,3} does not hold.
Takahashi will see the numbers written in each cell in random order. He will get disappointed when there is a line (vertical, horizontal, or diagonal) that satisfies the following condition.
- The first two squares he sees contain the same number, but the last square contains a different number.
Find the probability that Takahashi sees the numbers in all the squares without getting disappointed.
Constraints
- c _ {i,j}\in\lbrace1,2,3,4,5,6,7,8,9\rbrace\ (1\leq i\leq3,1\leq j\leq3)
- c _ {i,1}=c _ {i,2}=c _ {i,3} does not hold for any 1\leq i\leq3.
- c _ {1,j}=c _ {2,j}=c _ {3,j} does not hold for any 1\leq j\leq3.
- c _ {1,1}=c _ {2,2}=c _ {3,3} does not hold.
- c _ {3,1}=c _ {2,2}=c _ {1,3} does not hold.
Input
The input is given from Standard Input in the following format:
c _ {1,1} c _ {1,2} c _ {1,3}
c _ {2,1} c _ {2,2} c _ {2,3}
c _ {3,1} c _ {3,2} c _ {3,3}
Output
Print one line containing the probability that Takahashi sees the numbers in all the squares without getting disappointed. Your answer will be considered correct if the absolute error from the true value is at most 10 ^ {-8}.
Sample Input 1
3 1 9 2 5 6 2 7 1
Sample Output 1
0.666666666666666666666666666667
For example, if Takahashi sees c _ {3,1}=2,c _ {2,1}=2,c _ {1,1}=3 in this order, he will get disappointed.

On the other hand, if Takahashi sees c _ {1,1},c _ {1,2},c _ {1,3},c _ {2,1},c _ {2,2},c _ {2,3},c _ {3,1},c _ {3,2},c _ {3,3} in this order, he will see all numbers without getting disappointed.
The probability that Takahashi sees all the numbers without getting disappointed is \dfrac 23. Your answer will be considered correct if the absolute error from the true value is at most 10 ^ {-8}, so outputs such as 0.666666657 and 0.666666676 would also be accepted.
Sample Input 2
7 7 6 8 6 8 7 7 6
Sample Output 2
0.004982363315696649029982363316
Sample Input 3
3 6 7 1 9 7 5 7 5
Sample Output 3
0.4
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 400 点
問題文
以下の条件を満たす整数 k を「 250 に似た数」と呼びます。
- k が素数 p<q を使って k=p \times q^3 と表される。
N 以下の「 250 に似た数」は全部でいくつありますか?
制約
- N は 1 以上 10^{18} 以下の整数
入力
入力は以下の形式で標準入力から与えられる。
N
出力
答えを整数として出力せよ。
入力例 1
250
出力例 1
2
- 54 = 2 \times 3^3 なので、「 250 に似た数」です。
- 250 = 2 \times 5^3 なので、「 250 に似た数」です。
250 以下の「 250 に似た数」は、以上の 2 つです。
入力例 2
1
出力例 2
0
入力例 3
123456789012345
出力例 3
226863
Score : 400 points
Problem Statement
Let us regard an integer k as "similar to 250" if the following condition is satisfied:
- k is represented as k=p \times q^3 with primes p<q.
How many integers less than or equal to N are "similar to 250"?
Constraints
- N is an integer between 1 and 10^{18} (inclusive)
Input
Input is given from Standard Input in the following format:
N
Output
Print the answer as an integer.
Sample Input 1
250
Sample Output 1
2
- 54 = 2 \times 3^3 is "similar to 250".
- 250 = 2 \times 5^3 is "similar to 250".
The two integers above are all the integers "similar to 250".
Sample Input 2
1
Sample Output 2
0
Sample Input 3
123456789012345
Sample Output 3
226863
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 500 点
問題文
整数 M および N 個の整数の組 (A_1, B_1), (A_2, B_2), \dots, (A_N, B_N) が与えられます。
すべての i について 1 \leq A_i \lt B_i \leq M が成り立っています。
次の条件を満たす数列 S を良い数列と呼びます。
- S は数列 (1,2,3,..., M) の連続部分列である。
- すべての i について S は A_i, B_i の少なくとも一方を含んでいる。
長さ k の良い数列としてあり得るものの個数を f(k) とします。
f(1), f(2), \dots, f(M) を列挙してください。
制約
- 1 \leq N \leq 2 \times 10^5
- 2 \leq M \leq 2 \times 10^5
- 1 \leq A_i \lt B_i \leq M
- 入力される値はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N M A_1 B_1 A_2 B_2 \vdots A_N B_N
出力
答えを以下の形式で出力せよ。
f(1) f(2) \dots f(M)
入力例 1
3 5 1 3 1 4 2 5
出力例 1
0 1 3 2 1
良い数列としてあり得るものを列挙すると次のようになります。
- (1,2)
- (1,2,3)
- (2,3,4)
- (3,4,5)
- (1,2,3,4)
- (2,3,4,5)
- (1,2,3,4,5)
入力例 2
1 2 1 2
出力例 2
2 1
入力例 3
5 9 1 5 1 7 5 6 5 8 2 6
出力例 3
0 0 1 2 4 4 3 2 1
Score : 500 points
Problem Statement
You are given an integer M and N pairs of integers (A_1, B_1), (A_2, B_2), \dots, (A_N, B_N).
For all i, it holds that 1 \leq A_i \lt B_i \leq M.
A sequence S is said to be a good sequence if the following conditions are satisfied:
- S is a contiguous subsequence of the sequence (1,2,3,..., M).
- For all i, S contains at least one of A_i and B_i.
Let f(k) be the number of possible good sequences of length k.
Enumerate f(1), f(2), \dots, f(M).
Constraints
- 1 \leq N \leq 2 \times 10^5
- 2 \leq M \leq 2 \times 10^5
- 1 \leq A_i \lt B_i \leq M
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
N M A_1 B_1 A_2 B_2 \vdots A_N B_N
Output
Print the answers in the following format:
f(1) f(2) \dots f(M)
Sample Input 1
3 5 1 3 1 4 2 5
Sample Output 1
0 1 3 2 1
Here is the list of all possible good sequences.
- (1,2)
- (1,2,3)
- (2,3,4)
- (3,4,5)
- (1,2,3,4)
- (2,3,4,5)
- (1,2,3,4,5)
Sample Input 2
1 2 1 2
Sample Output 2
2 1
Sample Input 3
5 9 1 5 1 7 5 6 5 8 2 6
Sample Output 3
0 0 1 2 4 4 3 2 1
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 500 点
問題文
英小文字からなる長さ N の文字列 S と Q 個のクエリが与えられます。クエリを順に処理してください。
クエリは以下の 2 種類です。
1 x c: S の x 文字目を文字 c に置き換える2 l r: S を文字の昇順に並び替えて得られる文字列を T とする。S の l 文字目から r 文字目までからなる文字列が T の部分文字列であるときYes、部分文字列でないときNoを出力する
部分文字列とは?
S の部分文字列とは、S の先頭から 0 文字以上、末尾から 0 文字以上削除して得られる文字列のことをいいます。 例えば、ab は abc の部分文字列ですが、ac は abc の部分文字列ではありません。
制約
- 1\leq N \leq 10^5
- S は英小文字からなる長さ N の文字列
- 1 \leq Q \leq 10^5
- 1 種類目のクエリにおいて、1 \leq x \leq N
- 1 種類目のクエリにおいて、c は英小文字
- 2 種類目のクエリにおいて、1 \leq l \leq r \leq N
入力
入力は以下の形式で標準入力から与えられる。ただし、\text{query}_i で i 番目のクエリを表す。
N
S
Q
\text{query}_1
\text{query}_2
\vdots
\text{query}_Q
出力
問題文中の指示に従ってクエリを処理せよ。
入力例 1
6 abcdcf 4 2 1 3 2 2 6 1 5 e 2 2 6
出力例 1
Yes No Yes
- 1 番目のクエリにおいて、S を文字の昇順に並び替えて得られる文字列 T は
abccdfです。 S の 1 文字目から 3 文字目までからなる文字列はabcであり T の部分文字列です。よってYesを出力します。 - 2 番目のクエリにおいて、S を文字の昇順に並び替えて得られる文字列 T は
abccdfです。 S の 2 文字目から 6 文字目までからなる文字列はbcdcfであり T の部分文字列ではありません。よってNoを出力します。 - 3 番目のクエリにより、S の 5 文字目が
eに置き換えられ、S はabcdefとなります。 - 4 番目のクエリにおいて、S を文字の昇順に並び替えて得られる文字列 T は
abcdefです。 S の 2 文字目から 6 文字目までからなる文字列はbcdefであり T の部分文字列です。よってYesを出力します。
Score : 500 points
Problem Statement
You are given a string S of length N consisting of lowercase English letters, and Q queries. Process the queries in order.
Each query is of one of the following two kinds:
1 x c: replace the x-th character of S by the character c.2 l r: let T be the string obtained by sorting the characters of S in ascending order. PrintYesif the string consisting of the l-th through r-th characters of S is a substring of T; printNootherwise.
What is a substring?
A substring of S is a string obtained by removing 0 or more initial characters and 0 or more final characters of S. For example,ab is a substring of abc, while ac is not a substring of abc.
Constraints
- 1\leq N \leq 10^5
- S is a string of length N consisting of lowercase English letters.
- 1 \leq Q \leq 10^5
- For each query of the first kind, 1 \leq x \leq N.
- For each query of the first kind, c is a lowercase English letter.
- For each query of the second kind, 1 \leq l \leq r \leq N.
Input
The input is given from Standard Input in the following format, where \text{query}_i denotes the i-th query:
N
S
Q
\text{query}_1
\text{query}_2
\vdots
\text{query}_Q
Output
Process the queries as instructed in the Problem Statement.
Sample Input 1
6 abcdcf 4 2 1 3 2 2 6 1 5 e 2 2 6
Sample Output 1
Yes No Yes
- In the 1-st query,
abccdfis the string T obtained by sorting the characters of S in ascending order. The stringabc, consisting of the 1-st through 3-rd characters of S, is a substring of T, soYesshould be printed. - In the 2-nd query,
abccdfis the string T obtained by sorting the characters of S in ascending order. The stringbcdcf, consisting of the 2-nd through 6-th characters of S, is not a substring of T, soNoshould be printed. - The 3-rd query sets the 5-th character of S to
e, making Sabcdef. - In the 4-th query,
abcdefis the string T obtained by sorting the characters of S in ascending order. The stringbcdef, consisting of the 2-nd through 6-th characters of S, is a substring of T, soYesshould be printed.