A - Find Multiple

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 100

問題文

A 以上 B 以下であるような C の倍数を、1 つ出力してください。

条件を満たす数が存在しない場合は -1 を出力してください。

制約

  • 1 \leq A \leq B \leq 1000
  • 1 \leq C \leq 1000
  • 入力は全て整数

入力

入力は以下の形式で標準入力から与えられる。

A B C

出力

答えを出力せよ。
条件を満たす数が存在しない場合は -1 を出力せよ。


入力例 1

123 456 100

出力例 1

200

300400 も正解です。


入力例 2

630 940 314

出力例 2

-1

Score : 100 points

Problem Statement

Print a number between A and B (inclusive) that is a multiple of C.

If there is no such number, print -1.

Constraints

  • 1 \leq A \leq B \leq 1000
  • 1 \leq C \leq 1000
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

A B C

Output

Print the answer.
If there is no number with the desired property, print -1.


Sample Input 1

123 456 100

Sample Output 1

200

300 or 400 would also be accepted.


Sample Input 2

630 940 314

Sample Output 2

-1
B - Saturday

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 100

問題文

ある日、学校へ行くのに疲れてしまった高橋くんは、土曜日まであと何日あるかを知りたくなりました。
その日は平日で、曜日を英語で表すと S だったことが分かっています。その日より後の直近の土曜日は何日後かを求めてください。

なお、月曜日、火曜日、水曜日、木曜日、金曜日はそれぞれ英語で Monday, Tuesday, Wednesday, Thursday, Friday です。

制約

  • SMonday, Tuesday, Wednesday, Thursday, Friday のいずれかである

入力

入力は以下の形式で標準入力から与えられる。

S

出力

答えを整数として出力せよ。


入力例 1

Wednesday

出力例 1

3

この日は水曜日なので、3 日後に土曜日になります。


入力例 2

Monday

出力例 2

5

Score : 100 points

Problem Statement

One day, tired from going to school, Takahashi wanted to know how many days there were until Saturday.
We know that the day was a weekday, and the name of the day of the week was S in English.
How many days were there until the first Saturday after that day (including Saturday but not the starting day)?

Constraints

  • S is Monday, Tuesday, Wednesday, Thursday, or Friday.

Input

Input is given from Standard Input in the following format:

S

Output

Print the answer as an integer.


Sample Input 1

Wednesday

Sample Output 1

3

It was Wednesday, so there were 3 days until the first Saturday after that day.


Sample Input 2

Monday

Sample Output 2

5
C - AtCoder Quiz

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 200

問題文

AtCoder では現在、 ABC , ARC , AGC , AHC4 つのコンテストが定期的に開催されています。

AtCoder で現在定期的に開催されているコンテストは S_1 , S_2 , S_3 とあと 1 つは何ですか?

制約

  • S_1 , S_2 , S_3 はそれぞれ、 ABC , ARC , AGC , AHC のいずれかである。
  • S_1 , S_2 , S_3 は相異なる。

入力

入力は以下の形式で標準入力から与えられる。

S_1
S_2
S_3

出力

答えを出力せよ。


入力例 1

ARC
AGC
AHC

出力例 1

ABC

ARC , AGC , AHC3つが入力として与えられているので、 残りの 1 つはABC です。


入力例 2

AGC
ABC
ARC

出力例 2

AHC

Score : 200 points

Problem Statement

AtCoder currently holds four series of regular contests: ABC, ARC, AGC, and AHC.

What is the series of regular contests currently held by AtCoder in addition to S_1, S_2, and S_3?

Constraints

  • Each of S_1, S_2, and S_3 is ABC, ARC, AGC, or AHC.
  • S_1, S_2, and S_3 are pairwise different.

Input

Input is given from Standard Input in the following format:

S_1
S_2
S_3

Output

Print the answer.


Sample Input 1

ARC
AGC
AHC

Sample Output 1

ABC

Given in input are ARC, AGC, and AHC. The rest is ABC.


Sample Input 2

AGC
ABC
ARC

Sample Output 2

AHC
D - Vacation Together

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 200

問題文

1 から N までの番号がついた N 人の人がいます。
N 人の人の今後 D 日間の予定が与えられます。人 i の予定は長さ D の文字列 S_i で表されて、S_ij 文字目が o ならば j 日目は暇であることを、x ならばそうでないことを意味します。

D 日間のうち全員が暇であるような 連続する 何日かを選ぶことを考えます。
選べる日数は最大で何日ですか?ただし、選べる日が存在しない場合は 0 日と答えてください。

制約

  • 1 \leq N \leq 100
  • 1 \leq D \leq 100
  • N, D は整数
  • S_iox からなる長さ 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 o and x.

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
E - Σ

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 250

問題文

長さ N の正整数列 A=(A_1,A_2,\dots,A_N) および正整数 K が与えられます。

1 以上 K 以下の整数のうち、A の中に一度も現れないものの総和を求めてください。

制約

  • 1\leq N \leq 2\times 10^5
  • 1\leq K \leq 2\times 10^9
  • 1\leq A_i \leq 2\times 10^9
  • 入力は全て整数

入力

入力は以下の形式で標準入力から与えられる。

N K
A_1 A_2 \dots A_N

出力

答えを出力せよ。


入力例 1

4 5
1 6 3 1

出力例 1

11

1 以上 5 以下の整数のうち、A の中に一度も現れないものは 2,4,53 つです。

よって、それらの総和である 2+4+5=11 を出力します。


入力例 2

1 3
346

出力例 2

6

入力例 3

10 158260522
877914575 24979445 623690081 262703497 24979445 1822804784 1430302156 1161735902 923078537 1189330739

出力例 3

12523196466007058

Score: 250 points

Problem Statement

You are given a sequence of positive integers A=(A_1,A_2,\dots,A_N) of length N and a positive integer K.

Find the sum of the integers between 1 and K, inclusive, that do not appear in the sequence A.

Constraints

  • 1\leq N \leq 2\times 10^5
  • 1\leq K \leq 2\times 10^9
  • 1\leq A_i \leq 2\times 10^9
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

N K
A_1 A_2 \dots A_N

Output

Print the answer.


Sample Input 1

4 5
1 6 3 1

Sample Output 1

11

Among the integers between 1 and 5, three numbers, 2, 4, and 5, do not appear in A.

Thus, print their sum: 2+4+5=11.


Sample Input 2

1 3
346

Sample Output 2

6

Sample Input 3

10 158260522
877914575 24979445 623690081 262703497 24979445 1822804784 1430302156 1161735902 923078537 1189330739

Sample Output 3

12523196466007058
F - World Tour Finals

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 250

問題文

N 人のプレイヤーが参加するプログラミングコンテスト World Tour Finals が行われており、競技時間の半分が過ぎました。 このコンテストでは M 問の問題が出題されており、問題 i の点数 A_i500 以上 2500 以下の 100 の倍数です。

i = 1, \ldots, N について、プレイヤー i がどの問題を既に解いたかを表す文字列 S_i が与えられます。 S_io, x からなる長さ M の文字列で、S_ij 文字目が o のときプレイヤー i は問題 j を既に解いており、x のときまだ解いていません。 ただし、どのプレイヤーもまだ全ての問題を解いてはいません。

プレイヤー i の総合得点は、解いた問題の点数の合計に、ボーナス点 i 点を加えた点数として計算されます。
さて、各 i = 1, \ldots, N について以下の質問に答えてください。

  • プレイヤー i がまだ解いていない問題を少なくとも何問解くことで、プレイヤー i の総合得点が他のプレイヤー全員の現在の総合得点を上回ることができますか?

なお、問題文中の条件と制約から、プレイヤー i が全ての問題を解くことで、他のプレイヤー全員の現在の総合得点を上回ることができることが証明できます。 このことから、答えは常に定義されることに注意してください。

制約

  • 2\leq N\leq 100
  • 1\leq M\leq 100
  • 500\leq A_i\leq 2500
  • A_i100 の倍数
  • S_io, x からなる長さ M の文字列
  • S_i には x が一個以上含まれる
  • 入力される数値は全て整数

入力

入力は以下の形式で標準入力から与えられる。

N M
A_1 A_2 \ldots A_M
S_1
S_2
\vdots
S_N

出力

N 行出力せよ。 i 行目にはプレイヤー i に関する質問の答えを出力せよ。


入力例 1

3 4
1000 500 700 2000
xxxo
ooxx
oxox

出力例 1

0
1
1

競技時間の半分の経過時の各プレイヤーの総合得点は、プレイヤー 12001 点、プレイヤー 21502 点、プレイヤー 31703 点です。

プレイヤー 11 問も解かずとも、他のプレイヤー全員の総合得点を上回っています。

プレイヤー 2 は、例えば問題 4 を解けば総合得点が 3502 点となり、他のプレイヤー全員の総合得点を上回ります。

プレイヤー 3 も、例えば問題 4 を解けば総合得点が 3703 点となり、他のプレイヤー全員の総合得点を上回ります。


入力例 2

5 5
1000 1500 2000 2000 2500
xxxxx
oxxxx
xxxxx
oxxxx
oxxxx

出力例 2

1
1
1
1
0

入力例 3

7 8
500 500 500 500 500 500 500 500
xxxxxxxx
oxxxxxxx
ooxxxxxx
oooxxxxx
ooooxxxx
oooooxxx
ooooooxx

出力例 3

7
6
5
4
3
2
0

Score : 250 points

Problem Statement

The programming contest World Tour Finals is underway, where N players are participating, and half of the competition time has passed. There are M problems in this contest, and the score A_i of problem i is a multiple of 100 between 500 and 2500, inclusive.

For each i = 1, \ldots, N, you are given a string S_i that indicates which problems player i has already solved. S_i is a string of length M consisting of o and x, where the j-th character of S_i is o if player i has already solved problem j, and x if they have not yet solved it. Here, none of the players have solved all the problems yet.

The total score of player i is calculated as the sum of the scores of the problems they have solved, plus a bonus score of i points.
For each i = 1, \ldots, N, answer the following question.

  • At least how many of the problems that player i has not yet solved must player i solve to exceed all other players' current total scores?

Note that under the conditions in this statement and the constraints, it can be proved that player i can exceed all other players' current total scores by solving all the problems, so the answer is always defined.

Constraints

  • 2\leq N\leq 100
  • 1\leq M\leq 100
  • 500\leq A_i\leq 2500
  • A_i is a multiple of 100.
  • S_i is a string of length M consisting of o and x.
  • S_i contains at least one x.
  • All numeric values in the input are integers.

Input

The input is given from Standard Input in the following format:

N M
A_1 A_2 \ldots A_M
S_1
S_2
\vdots
S_N

Output

Print N lines. The i-th line should contain the answer to the question for player i.


Sample Input 1

3 4
1000 500 700 2000
xxxo
ooxx
oxox

Sample Output 1

0
1
1

The players' total scores at the halfway point of the competition time are 2001 points for player 1, 1502 points for player 2, and 1703 points for player 3.

Player 1 is already ahead of all other players' total scores without solving any more problems.

Player 2 can, for example, solve problem 4 to have a total score of 3502 points, which would exceed all other players' total scores.

Player 3 can also, for example, solve problem 4 to have a total score of 3703 points, which would exceed all other players' total scores.


Sample Input 2

5 5
1000 1500 2000 2000 2500
xxxxx
oxxxx
xxxxx
oxxxx
oxxxx

Sample Output 2

1
1
1
1
0

Sample Input 3

7 8
500 500 500 500 500 500 500 500
xxxxxxxx
oxxxxxxx
ooxxxxxx
oooxxxxx
ooooxxxx
oooooxxx
ooooooxx

Sample Output 3

7
6
5
4
3
2
0
G - Unique Username

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 400

問題文

高橋君はあるサービスで使うユーザー名を決めるのに困っています。彼を助けるプログラムを書いてください。

以下の条件をすべて満たす文字列 X1 つ求めてください。

  • X は次の手順で得られる文字列である。
    • N 個の文字列 S_1,S_2,\ldots,S_N を好きな順番で並べたものを S_1', S_2', \ldots,S_N' とする。そして、S_1'、( 1 個以上の _ )、S_2'、( 1 個以上の _ )、\ldots、( 1 個以上の _ )、S_N' をこの順番で連結したものを X とする。
  • X の文字数は 3 以上 16 以下である。
  • XM 個の文字列 T_1,T_2,\ldots,T_M のいずれとも一致しない。

ただし、条件をすべて満たす文字列 X が存在しない場合は代わりに -1 と出力してください。

制約

  • 1 \leq N \leq 8
  • 0 \leq M \leq 10^5
  • N,M は整数
  • 1 \leq |S_i| \leq 16
  • N-1+\sum{|S_i|} \leq 16
  • i \neq j ならば S_i \neq S_j
  • S_i は英小文字のみからなる文字列
  • 3 \leq |T_i| \leq 16
  • i \neq j ならば T_i \neq T_j
  • T_i は英小文字と _ のみからなる文字列

入力

入力は以下の形式で標準入力から与えられる。

N M
S_1
S_2
\vdots
S_N
T_1
T_2
\vdots
T_M

出力

条件をすべて満たす文字列 X1 つ出力せよ。ただし、条件をすべて満たす文字列 X が存在しない場合は代わりに -1 を出力せよ。
答えが複数存在する場合、どれを出力しても良い。


入力例 1

1 1
chokudai
chokudai

出力例 1

-1

条件のうち 1 番目と 2 番目を満たす文字列は X= chokudai しかありませんが、これは T_1 と一致します。
このため、条件をすべて満たす文字列 X が存在せず、-1 が正しい出力となります。


入力例 2

2 2
choku
dai
chokudai
choku_dai

出力例 2

dai_choku

この他に、choku__dai (chokudai の間の _2 つ) 等も条件をすべて満たします。


入力例 3

2 2
chokudai
atcoder
chokudai_atcoder
atcoder_chokudai

出力例 3

-1

chokudai__atcoderatcoder__chokudai (chokudaiatcoder の間の _2 つ)は文字数が 17 なので 2 番目の条件を満たしません。


入力例 4

4 4
ab
cd
ef
gh
hoge
fuga
____
_ab_cd_ef_gh_

出力例 4

ab__ef___cd_gh

1 番目の条件で記述されている操作で得られないような文字列が T_i として与えられる場合があります。

Score : 400 points

Problem Statement

Takahashi is having trouble with deciding a username for a service. Write a code to help him.

Find a string X that satisfies all of the following conditions:

  • X is obtained by the following procedure:
    • Let S_1', S_2', \ldots,S_N' be a permutation of S_1, S_2, \ldots,S_N. Let X be the concatenation of S_1', (1 or more copies of _), S_2', (1 or more copies of _), \ldots, (1 or more copies of _), and S_N', in this order.
  • The length of X is between 3 and 16, inclusive.
  • X does not coincide with any of M strings T_1,T_2,\ldots,T_M.

If there is no X that satisfies all of the conditions, print -1 instead.

Constraints

  • 1 \leq N \leq 8
  • 0 \leq M \leq 10^5
  • N and M are integers.
  • 1 \leq |S_i| \leq 16
  • N-1+\sum{|S_i|} \leq 16
  • S_i \neq S_j if i \neq j.
  • S_i is a string consisting of lowercase English letters.
  • 3 \leq |T_i| \leq 16
  • T_i \neq T_j if i \neq j.
  • T_i is a string consisting of lowercase English letters and _.

Input

Input is given from Standard Input in the following format:

N M
S_1
S_2
\vdots
S_N
T_1
T_2
\vdots
T_M

Output

Print a string X that satisfies all of the conditions. If there is no X that satisfies all of the conditions, print -1 instead.
If there are multiple solutions, print any of them.


Sample Input 1

1 1
chokudai
chokudai

Sample Output 1

-1

The only string that satisfies the first and second conditions is X= chokudai, but it coincides with T_1.
Thus, there is no X that satisfies all of the conditions, so -1 should be printed.


Sample Input 2

2 2
choku
dai
chokudai
choku_dai

Sample Output 2

dai_choku

Strings like choku__dai (which has two _'s between choku and dai) also satisfy all of the conditions.


Sample Input 3

2 2
chokudai
atcoder
chokudai_atcoder
atcoder_chokudai

Sample Output 3

-1

chokudai__atcoder and atcoder__chokudai (which have two _'s between chokudai and atcoder) have a length of 17, which violates the second condition.


Sample Input 4

4 4
ab
cd
ef
gh
hoge
fuga
____
_ab_cd_ef_gh_

Sample Output 4

ab__ef___cd_gh

The given T_i may contain a string that cannot be obtained by the procedure described in the first condition.

H - Remove Pairs

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 475

問題文

高橋君と青木君は N 枚のカードを使ってとあるゲームをします。i 枚目のカードの表面には A_i が、裏面には B_i が書かれています。初めに場には N 枚のカードが並べられており、高橋君を先手として、2 人は以下の操作を交互に繰り返します。

  • 場にあるカードの中から表面同士に同じ数が書かれている、または裏面同士に同じ数が書かれている 2 枚のカードの組を選び、そのカードを場から取り除く。このようなカードの組が存在しない場合、操作を行えない。

先に操作を行えなくなった方が負けとなり、もう一方が勝ちとなります。 両者がそれぞれ勝つために最適な操作を選ぶ時、どちらが勝つか求めてください。

制約

  • 1 \leq N \leq 18
  • 1 \leq A_i,B_i \leq 10^9
  • 入力は全て整数である。

入力

入力は以下の形式で標準入力から与えられる。

N
A_1 B_1
A_2 B_2
\vdots
A_N B_N

出力

2 人とも最適に操作を行なったとき、高橋君が勝つ場合は Takahashi と、青木君が勝つ場合は Aoki と出力せよ。


入力例 1

5
1 9
2 5
4 9
1 4
2 5

出力例 1

Aoki

髙橋君が最初に取り除いた 2 枚が

  • 1 枚目と 3 枚目のカードだった場合: 青木君は 2 枚目と 5 枚目のカードを取り除くことで勝つことができる。

  • 1 枚目と 4 枚目のカードだった場合: 青木君は 2 枚目と 5 枚目のカードを取り除くことで勝つことができる。

  • 2 枚目と 5 枚目のカードだった場合: 青木君は 1 枚目と 3 枚目のカードを取り除くことで勝つことができる。

髙橋君が最初の操作で取り除くことができるカードの組み合わせは以上の 3 通りのみで、髙橋君がどのような操作を行っても青木君が勝つことができるため、青木君が答えとなります。


入力例 2

9
3 2
1 7
4 1
1 8
5 2
9 8
2 1
6 8
5 2

出力例 2

Takahashi

Score : 475 points

Problem Statement

Takahashi and Aoki are playing a game using N cards. The front side of the i-th card has A_i written on it, and the back side has B_i written on it. Initially, the N cards are laid out on the table. With Takahashi going first, the two players take turns performing the following operation:

  • Choose a pair of cards from the table such that either the numbers on their front sides are the same or the numbers on their back sides are the same, and remove these two cards from the table. If no such pair of cards exists, the player cannot perform the operation.

The player who is first to be unable to perform the operation loses, and the other player wins. Determine who wins if both players play optimally.

Constraints

  • 1 \leq N \leq 18
  • 1 \leq A_i, B_i \leq 10^9
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

N
A_1 B_1
A_2 B_2
\vdots
A_N B_N

Output

Print Takahashi if Takahashi wins when both players play optimally, and Aoki otherwise.


Sample Input 1

5
1 9
2 5
4 9
1 4
2 5

Sample Output 1

Aoki

If Takahashi first removes

  • the first and third cards: Aoki can win by removing the second and fifth cards.

  • the first and fourth cards: Aoki can win by removing the second and fifth cards.

  • the second and fifth cards: Aoki can win by removing the first and third cards.

These are the only three pairs of cards Takahashi can remove in his first move, and Aoki can win in all cases. Therefore, the answer is Aoki.


Sample Input 2

9
3 2
1 7
4 1
1 8
5 2
9 8
2 1
6 8
5 2

Sample Output 2

Takahashi
I - Parenthesis Checking

実行時間制限: 3 sec / メモリ制限: 1024 MiB

配点 : 500

問題文

以下のいずれかの条件を満たす文字列を正しい括弧列と定義します。

  • 空文字列
  • ある正しい括弧列 A が存在して、(, A, ) をこの順に連結した文字列
  • ある空でない正しい括弧列 A, B が存在して、A, B をこの順に連結した文字列

() のみからなる長さ N の文字列 S があります。

Q 個のクエリ \text{Query}_1,\text{Query}_2,\ldots,\text{Query}_Q が与えられるので、順番に処理してください。クエリには 2 種類があり、入力形式とクエリの内容は以下の通りです。

  • 1 l r : Sl 文字目と r 文字目を入れ替える。
  • 2 l r : Sl 文字目から r 文字目までの連続部分文字列が正しい括弧列であるか判定する。

制約

  • 1 \leq N,Q \leq 2 \times 10^5
  • S() のみからなる長さ N の文字列
  • 1 \leq l < r \leq N
  • N,Q,l,r はいずれも整数
  • 各クエリは 1 l r2 l r のいずれかの形式で与えられる。
  • 2 l r の形式のクエリは 1 つ以上与えられる。

入力

入力は以下の形式で標準入力から与えられる。

N Q
S
\text{Query}_1
\text{Query}_2
\vdots
\text{Query}_Q

出力

2 l r の形式の各クエリに対して、連続部分文字列が正しい括弧列である場合 Yes、そうでない場合 No と出力し、改行せよ。


入力例 1

5 3
(())(
2 1 4
2 1 2
2 4 5

出力例 1

Yes
No
No

1 つ目のクエリにおいて、(())正しい括弧列です。

2 つ目のクエリにおいて、((正しい括弧列ではありません。

3 つ目のクエリにおいて、)(正しい括弧列ではありません。


入力例 2

5 3
(())(
2 1 4
1 1 4
2 1 4

出力例 2

Yes
No

1 つ目のクエリにおいて、(())正しい括弧列です。

2 つ目のクエリによって、S)()(( となります。

3 つ目のクエリにおいて、)()(正しい括弧列ではありません。


入力例 3

8 8
(()(()))
2 2 7
2 2 8
1 2 5
2 3 4
1 3 4
1 3 5
1 1 4
1 6 8

出力例 3

Yes
No
No

Score : 500 points

Problem Statement

Let us define a correct parenthesis sequence as a string that satisfies one of the following conditions.

  • It is an empty string.
  • It is a concatenation of (, A, ), in this order, for some correct parenthesis sequence A.
  • It is a concatenation of A, B, in this order, for some correct parenthesis sequences A and B.

We have a string S of length N consisting of ( and ).

Given Q queries \text{Query}_1,\text{Query}_2,\ldots,\text{Query}_Q, process them in order. There are two kinds of queries, with the following formats and content.

  • 1 l r: Swap the l-th and r-th characters of S.
  • 2 l r: Determine whether the contiguous substring from the l-th through the r-th character is a correct parenthesis sequence.

Constraints

  • 1 \leq N,Q \leq 2 \times 10^5
  • S is a string of length N consisting of ( and ).
  • 1 \leq l < r \leq N
  • N,Q,l,r are all integers.
  • Each query is in the format 1 l r or 2 l r.
  • There is at least one query in the format 2 l r.

Input

Input is given from Standard Input in the following format:

N Q
S
\text{Query}_1
\text{Query}_2
\vdots
\text{Query}_Q

Output

For each query in the format 2 l r, print Yes if the contiguous substring is a correct parenthesis sequence, and No otherwise, followed by a newline.


Sample Input 1

5 3
(())(
2 1 4
2 1 2
2 4 5

Sample Output 1

Yes
No
No

In the first query, (()) is a correct parenthesis sequence.

In the second query, (( is not a correct parenthesis sequence.

In the third query, )( is not a correct parenthesis sequence.


Sample Input 2

5 3
(())(
2 1 4
1 1 4
2 1 4

Sample Output 2

Yes
No

In the first query, (()) is a correct parenthesis sequence.

In the second query, S becomes )()((.

In the third query, )()( is not a correct parenthesis sequence.


Sample Input 3

8 8
(()(()))
2 2 7
2 2 8
1 2 5
2 3 4
1 3 4
1 3 5
1 1 4
1 6 8

Sample Output 3

Yes
No
No