A - Black Square

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 100 点

問題文

10^{100} 行 10^{100} 列のマス目があります。
以下では、上から i 行目かつ左から j 列目のマスをマス (i,j) と表します。

マス目のうち、マス (P,Q) を一番左上のマスとした 100\times 100 マスの領域のみが黒く塗られており、それ以外のマスは白く塗られています。
マス (X,Y) が黒く塗られているか判定してください。

制約

  • 1 \leq P,Q,X,Y \leq 10000
  • P,Q,X,Y は整数

入力

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

P Q
X Y

出力

マス (X,Y) が黒く塗られているならば Yes を、そうでないならば No を出力せよ。


入力例 1

3 3
5 10

出力例 1

Yes

マス (3,3) を最も左上のマスとする 100\times 100 マスの領域が黒く塗られています。
マス (5,10) はこの領域に含まれているため、Yes を出力します。


入力例 2

5 5
10 1000

出力例 2

No

マス (5,5) を最も左上のマスとする 100\times 100 マスの領域が黒く塗られています。
マス (10,1000) はこの領域に含まれていないため、No を出力します。


入力例 3

1 2
1 1

出力例 3

No

マス (1,2) を最も左上のマスとする 100\times 100 マスの領域が黒く塗られています。
マス (1,1) はこの領域に含まれていないため、No を出力します。

Score : 100 points

Problem Statement

There is a grid with 10^{100} rows and 10^{100} columns.
In what follows, the cell at the i-th row from the top and j-th column from the left is denoted as cell (i,j).

In this grid, only the 100\times 100 region with cell (P,Q) as the top-left cell is painted black, and all other cells are painted white.
Determine whether cell (X,Y) is painted black.

Constraints

  • 1 \leq P,Q,X,Y \leq 10000
  • P,Q,X,Y are integers.

Input

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

P Q
X Y

Output

If cell (X,Y) is painted black, print Yes; otherwise, print No.


Sample Input 1

3 3
5 10

Sample Output 1

Yes

The 100\times 100 region with cell (3,3) as the top-left cell is painted black.
Cell (5,10) is included in this region, so print Yes.


Sample Input 2

5 5
10 1000

Sample Output 2

No

The 100\times 100 region with cell (5,5) as the top-left cell is painted black.
Cell (10,1000) is not included in this region, so print No.


Sample Input 3

1 2
1 1

Sample Output 3

No

The 100\times 100 region with cell (1,2) as the top-left cell is painted black.
Cell (1,1) is not included in this region, so print No.

B - Find Takahashi

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 100 点

問題文

AtCoder 村には N 本の橋があり、i 本目( i は 1 以上 N 以下の整数)の橋の高さは H_i です。
ここで、AtCoder 村にある N 本の橋のうち、どの相異なる 2 本の橋も高さが異なります。

AtCoder 村で最も高い橋は何本目の橋か出力してください。

制約

  • 1\leq N \leq 100
  • 1\leq H_i \leq 10^9
  • H_i はすべて異なる
  • 入力はすべて整数

入力

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

N
H_1 H_2 \ldots H_N

出力

AtCoder 村で最も高い橋は何本目の橋かを、整数で出力せよ。


入力例 1

3
50 80 70

出力例 1

2

AtCoder 村には 3 本の橋があります。
1,2,3 本目の橋の高さはそれぞれ, 50,80,70 であり、 最も高い橋は 2 本目の橋です。
よって、2 を出力します。


入力例 2

1
1000000000

出力例 2

1

AtCoder 村に橋が 1 本しか存在しないため、2 本目以降の橋は存在せず、最も高い橋は 1 本目の橋となります。


入力例 3

10
22 75 26 45 72 81 47 29 97 2

出力例 3

9

AtCoder 村には 10 本の橋があり、それらのうち最も高い橋は 9 番目の橋(高さは 97 )です。

Score : 100 points

Problem Statement

There are N bridges in AtCoder Village. The height of the bridge numbered i is H_i (i is an integer between 1 and N).
Every two different bridges in the village have different heights.

Print the number representing the highest bridge in the village.

Constraints

  • 1\leq N \leq 100
  • 1\leq H_i \leq 10^9
  • All H_i are different.
  • All values in the input are integers.

Input

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

N
H_1 H_2 \ldots H_N

Output

Print the integer representing the highest bridge in AtCoder village.


Sample Input 1

3
50 80 70

Sample Output 1

2

The village has three bridges.
The first, second, and third bridges have heights of 50, 80, and 70, respectively, so the second bridge is the highest.
Thus, 2 should be printed.


Sample Input 2

1
1000000000

Sample Output 2

1

The village has only one bridge, so the first bridge is the highest.


Sample Input 3

10
22 75 26 45 72 81 47 29 97 2

Sample Output 3

9

The village has ten bridges, and the ninth bridge (with a height of 97) is the highest.

C - racecar

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 200 点

問題文

英小文字のみからなる N 個の文字列 S_1,S_2,\ldots,S_N が与えられます。
1 以上 N 以下の 相異なる 整数 i,j であって、S_i と S_j をこの順に連結した文字列が回文となるようなものが存在するか判定してください。

ただし、長さ M の文字列 T が回文であるとは、任意の 1\leq i\leq M について、T の i 文字目と (M+1-i) 文字目が一致していることをいいます。

制約

  • 2\leq N\leq 100
  • 1\leq \lvert S_i\rvert \leq 50
  • N は整数
  • S_i は英小文字のみからなる文字列
  • S_i はすべて異なる。

入力

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

N
S_1
S_2
\vdots
S_N

出力

問題文の条件をみたす i,j が存在するならば Yes を、そうでないならば No を出力せよ。


入力例 1

5
ab
ccef
da
a
fe

出力例 1

Yes

(i,j)=(1,4) とすると、S_1=ab と S_4=a をこの順に連結した文字列は aba となり、 これは回文であるため条件をみたしています。
よって、Yes を出力します。

また、(i,j)=(5,2) としても、S_5=fe と S_2=ccef をこの順に連結した文字列は feccef となり、やはり条件をみたしています。


入力例 2

3
a
b
aba

出力例 2

No

S_1, S_2, S_3 のうち、どの相異なる 2 つの文字列を繋げても回文となりません。 よって、No を出力します。
問題文における i,j は相異なる必要があることに注意してください。


入力例 3

2
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

出力例 3

Yes

Score : 200 points

Problem Statement

You are given N strings S_1,S_2,\ldots,S_N consisting of lowercase English letters.
Determine if there are distinct integers i and j between 1 and N, inclusive, such that the concatenation of S_i and S_j in this order is a palindrome.

A string T of length M is a palindrome if and only if the i-th character and the (M+1-i)-th character of T are the same for every 1\leq i\leq M.

Constraints

  • 2\leq N\leq 100
  • 1\leq \lvert S_i\rvert \leq 50
  • N is an integer.
  • S_i is a string consisting of lowercase English letters.
  • All S_i are distinct.

Input

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

N
S_1
S_2
\vdots
S_N

Output

If there are i and j that satisfy the condition in the problem statement, print Yes; otherwise, print No.


Sample Input 1

5
ab
ccef
da
a
fe

Sample Output 1

Yes

If we take (i,j)=(1,4), the concatenation of S_1=ab and S_4=a in this order is aba, which is a palindrome, satisfying the condition.
Thus, print Yes.

Here, we can also take (i,j)=(5,2), for which the concatenation of S_5=fe and S_2=ccef in this order is feccef, satisfying the condition.


Sample Input 2

3
a
b
aba

Sample Output 2

No

No two distinct strings among S_1, S_2, and S_3 form a palindrome when concatenated. Thus, print No.
Note that the i and j in the statement must be distinct.


Sample Input 3

2
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

Sample Output 3

Yes
D - 456

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 200 点

問題文

6 つの面を持つサイコロが 3 個あります。
i 個目のサイコロの j 個目の面には A_{i,j} が書かれています。
どのサイコロも、各面が出る確率は \frac{1}{6} です。

これらのサイコロを同時に振ったとき、4,5,6 の書かれた目が 1 つずつ出る確率を求めてください。

制約

  • A_{i,j} は 1 以上 6 以下の整数

入力

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

A_{1,1} A_{1,2} A_{1,3} A_{1,4} A_{1,5} A_{1,6}
A_{2,1} A_{2,2} A_{2,3} A_{2,4} A_{2,5} A_{2,6}
A_{3,1} A_{3,2} A_{3,3} A_{3,4} A_{3,5} A_{3,6}

出力

答えを出力せよ。 真の解との絶対誤差または相対誤差が 10^{-6} 以下のとき正解とみなされる。


入力例 1

1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6

出力例 1

0.0277777778

求める確率は \frac{1}{36} です。 0.027778 などの出力でも正解となります。


入力例 2

4 5 6 4 5 6
4 4 5 5 6 6
6 5 4 4 5 6

出力例 2

0.2222222222

求める確率は \frac{2}{9} です。

Score : 200 points

Problem Statement

There are three dice, each with six faces.
The j-th face of the i-th die has A_{i,j} written on it.
For each die, each face comes up with probability \frac{1}{6}.

When these dice are rolled simultaneously, find the probability that the values 4,5,6 each appear exactly once.

Constraints

  • A_{i,j} is an integer between 1 and 6, inclusive.

Input

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

A_{1,1} A_{1,2} A_{1,3} A_{1,4} A_{1,5} A_{1,6}
A_{2,1} A_{2,2} A_{2,3} A_{2,4} A_{2,5} A_{2,6}
A_{3,1} A_{3,2} A_{3,3} A_{3,4} A_{3,5} A_{3,6}

Output

Output the answer. The answer is considered correct if the absolute or relative error from the true answer is at most 10^{-6}.


Sample Input 1

1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6

Sample Output 1

0.0277777778

The desired probability is \frac{1}{36}. An output such as 0.027778 is also accepted.


Sample Input 2

4 5 6 4 5 6
4 4 5 5 6 6
6 5 4 4 5 6

Sample Output 2

0.2222222222

The desired probability is \frac{2}{9}.

E - Dice Sum

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 300 点

問題文

長さ N の整数からなる数列 A=(A_1,\ldots,A_N) であって、以下の条件を全て満たすものは何通りありますか?

  • 1\le A_i \le M (1 \le i \le N)

  • \displaystyle\sum _{i=1}^N A_i \leq K

ただし、答えは非常に大きくなることがあるので、答えを 998244353 で割った余りを求めてください。

制約

  • 1 \leq N, M \leq 50
  • N \leq K \leq NM
  • 入力は全て整数

入力

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

N M K

出力

答えを 998244353 で割った余りを出力せよ。


入力例 1

2 3 4

出力例 1

6

条件を満たす数列は以下の 6 つです。

  • (1,1)
  • (1,2)
  • (1,3)
  • (2,1)
  • (2,2)
  • (3,1)

入力例 2

31 41 592

出力例 2

798416518

答えを 998244353 で割った余りを出力してください。

Score : 300 points

Problem Statement

How many integer sequences of length N, A=(A_1, \ldots, A_N), satisfy all of the conditions below?

  • 1\le A_i \le M (1 \le i \le N)

  • \displaystyle\sum _{i=1}^N A_i \leq K

Since the count can get enormous, find it modulo 998244353.

Constraints

  • 1 \leq N, M \leq 50
  • N \leq K \leq NM
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

N M K

Output

Print the answer.


Sample Input 1

2 3 4

Sample Output 1

6

The following six sequences satisfy the conditions.

  • (1,1)
  • (1,2)
  • (1,3)
  • (2,1)
  • (2,2)
  • (3,1)

Sample Input 2

31 41 592

Sample Output 2

798416518

Be sure to print the count modulo 998244353.