A - Capitalized?

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 100

問題文

英大文字・英小文字からなる空でない文字列 S が与えられます。以下の条件が満たされているか判定してください。

  • S の先頭の文字は大文字であり、それ以外の文字はすべて小文字である。

制約

  • 1 \leq |S| \leq 100|S| は文字列 S の長さ)
  • S の各文字は英大文字または英小文字である。

入力

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

S

出力

条件が満たされていれば Yes、そうでなければ No を出力せよ。


入力例 1

Capitalized

出力例 1

Yes

Capitalized の先頭の文字 C は大文字であり、それ以外の文字 apitalized はすべて小文字であるため、Yes を出力します。


入力例 2

AtCoder

出力例 2

No

AtCoder は先頭以外にも大文字 C を含むため、No を出力します。


入力例 3

yes

出力例 3

No

yes の先頭の文字 y は大文字でないため、No を出力します。


入力例 4

A

出力例 4

Yes

Score: 100 points

Problem Statement

You are given a non-empty string S consisting of uppercase and lowercase English letters. Determine whether the following condition is satisfied:

  • The first character of S is uppercase, and all other characters are lowercase.

Constraints

  • 1 \leq |S| \leq 100 (|S| is the length of the string S.)
  • Each character of S is an uppercase or lowercase English letter.

Input

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

S

Output

If the condition is satisfied, print Yes; otherwise, print No.


Sample Input 1

Capitalized

Sample Output 1

Yes

The first character C of Capitalized is uppercase, and all other characters apitalized are lowercase, so you should print Yes.


Sample Input 2

AtCoder

Sample Output 2

No

AtCoder contains an uppercase letter C that is not at the beginning, so you should print No.


Sample Input 3

yes

Sample Output 3

No

The first character y of yes is not uppercase, so you should print No.


Sample Input 4

A

Sample Output 4

Yes
B - Batting Average

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 100

問題文

高橋君は野球ゲームを作っています。
高橋君はバッターの打率を指定された桁数の分だけ表示するプログラムを作ることにしました。

整数 A, B があります。ここで A, B1 \leq A \leq 10, 0 \leq B \leq A を満たします。
このとき、文字列 S を次のように定義します。

  • \dfrac{B}{A} を小数点第 4 位で四捨五入した値を「整数部 1 桁」「 . 」「小数部 3 桁」の順に末尾ゼロを省略せずに表記した文字列。

例えば A=7, B = 4 の場合は、\dfrac{B}{A} = \dfrac{4}{7} = 0.571428\dots で、これを小数点第 4 位で四捨五入した値は 0.571 です。よって S0.571 になります。

A, B が入力として与えられるので S を出力してください。

制約

  • 1 \leq A \leq 10
  • 0 \leq B \leq A
  • A, B は整数

入力

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

A B

出力

S を問題文の指示に従った形式で出力せよ。問題文の指示と異なる形式で出力した場合は誤答となることに注意せよ。


入力例 1

7 4

出力例 1

0.571

問題文本文でも説明した通り、\dfrac{B}{A} = \dfrac{4}{7} = 0.571428\dots で、これを小数点第 4 位で四捨五入した値は 0.571 です。よって S0.571 になります。


入力例 2

7 3

出力例 2

0.429

\dfrac{B}{A} = \dfrac{3}{7} = 0.428571\dots で、これを小数点第 4 位で四捨五入した値は 0.429 です。(繰り上がりが発生するのに注意してください。)
よって S0.429 となります。


入力例 3

2 1

出力例 3

0.500

\dfrac{B}{A} = \dfrac{1}{2} = 0.5 で、これを小数点第 4 位で四捨五入した値も同様に 0.5 です。
よって S0.500 となります。小数部を 3 桁並べる必要があるのに注意してください。


入力例 4

10 10

出力例 4

1.000

入力例 5

1 0

出力例 5

0.000

Score : 100 points

Problem Statement

Takahashi is making a computer baseball game.
He will write a program that shows a batter's batting average with a specified number of digits.

There are integers A and B, which satisfy 1 \leq A \leq 10 and 0 \leq B \leq A.
Let S be the string obtained as follows.

  • Round off \dfrac{B}{A} to three decimal digits, then write the integer part (1 digit), . (the decimal point), and the decimal part (3 digits) in this order, with trailing zeros.

For example, if A=7 and B=4, then \dfrac{B}{A} = \dfrac{4}{7} = 0.571428\dots rounded off to three decimal digits is 0.571. Thus, S is 0.571.

You are given A and B as the input and asked to print S.

Constraints

  • 1 \leq A \leq 10
  • 0 \leq B \leq A
  • A and B are integers.

Input

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

A B

Output

Print S in the format specified in the Problem Statement. Note that answers in different formats will be considered wrong.


Sample Input 1

7 4

Sample Output 1

0.571

As explained in the Problem Statement, \dfrac{B}{A} = \dfrac{4}{7} = 0.571428\dots rounded off to three decimal digits is 0.571. Thus, S is 0.571.


Sample Input 2

7 3

Sample Output 2

0.429

\dfrac{B}{A} = \dfrac{3}{7} = 0.428571\dots rounded off to three decimal digits is 0.429. (Note that it got rounded up.)
Thus, S is 0.429.


Sample Input 3

2 1

Sample Output 3

0.500

\dfrac{B}{A} = \dfrac{1}{2} = 0.5 rounded off to three decimal digits is again 0.5.
Thus, S is 0.500. Note that it must have three decimal places.


Sample Input 4

10 10

Sample Output 4

1.000

Sample Input 5

1 0

Sample Output 5

0.000
C - Adjacency Matrix

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 150

問題文

N 頂点の単純無向グラフ G があり、グラフの頂点には 1,2,\ldots, N の番号が付けられています。

G の隣接行列 (A_{i,j}) が与えられます。すなわち、GA_{i,j} = 1 であるとき、またそのときに限り頂点 i と頂点 j を結ぶ辺を持ちます。

i = 1, 2, \ldots, N について、頂点 i と直接結ばれている頂点の番号を昇順に出力してください。

ただし、頂点 i と頂点 j が直接結ばれているとは、頂点 i と頂点 j を結ぶ辺が存在することをいいます。

制約

  • 2 \leq N \leq 100
  • A_{i,j} \in \lbrace 0,1 \rbrace
  • A_{i,i} = 0
  • A_{i,j} = A_{j,i}
  • 入力される値はすべて整数

入力

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

N
A_{1,1} A_{1,2} \ldots A_{1,N}
A_{2,1} A_{2,2} \ldots A_{2,N}
\vdots
A_{N,1} A_{N,2} \ldots A_{N,N}

出力

N 行出力せよ。 i 行目には頂点 i と直接結ばれている頂点の番号を昇順に空白区切りで出力せよ。


入力例 1

4
0 1 1 0
1 0 0 1
1 0 0 0
0 1 0 0

出力例 1

2 3
1 4
1
2

頂点 1 と直接結ばれている頂点は頂点 2, 3 です。したがって、1 行目には 2, 3 をこの順で出力します。

同様に、2 行目には 1, 4 をこの順に、3 行目には 1 を、4 行目には 2 を出力します。


入力例 2

2
0 0
0 0

出力例 2



G に辺が存在しないこともあります。


入力例 3

5
0 1 0 1 1
1 0 0 1 0
0 0 0 0 1
1 1 0 0 1
1 0 1 1 0

出力例 3

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

Score: 150 points

Problem Statement

There is a simple undirected graph G with N vertices labeled with numbers 1, 2, \ldots, N.

You are given the adjacency matrix (A_{i,j}) of G. That is, G has an edge connecting vertices i and j if and only if A_{i,j} = 1.

For each i = 1, 2, \ldots, N, print the numbers of the vertices directly connected to vertex i in ascending order.

Here, vertices i and j are said to be directly connected if and only if there is an edge connecting vertices i and j.

Constraints

  • 2 \leq N \leq 100
  • A_{i,j} \in \lbrace 0,1 \rbrace
  • A_{i,i} = 0
  • A_{i,j} = A_{j,i}
  • All input values are integers.

Input

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

N
A_{1,1} A_{1,2} \ldots A_{1,N}
A_{2,1} A_{2,2} \ldots A_{2,N}
\vdots
A_{N,1} A_{N,2} \ldots A_{N,N}

Output

Print N lines. The i-th line should contain the numbers of the vertices directly connected to vertex i in ascending order, separated by a space.


Sample Input 1

4
0 1 1 0
1 0 0 1
1 0 0 0
0 1 0 0

Sample Output 1

2 3
1 4
1
2

Vertex 1 is directly connected to vertices 2 and 3. Thus, the first line should contain 2 and 3 in this order.

Similarly, the second line should contain 1 and 4 in this order, the third line should contain 1, and the fourth line should contain 2.


Sample Input 2

2
0 0
0 0

Sample Output 2



G may have no edges.


Sample Input 3

5
0 1 0 1 1
1 0 0 1 0
0 0 0 0 1
1 1 0 0 1
1 0 1 1 0

Sample Output 3

2 4 5
1 4
5
1 2 5
1 3 4
D - Decode Time Signal

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 200

問題文

AtCoder Land では時報がモールス信号で行なわれます。高橋君はこのモールス信号を解読したいです。

N 個の文字列 S_1, S_2, \ldots, S_N が与えられます。S_i (1 \leq i \leq N).- からなる文字列で、0 以上 9 以下のある数字に対応するモールス符号です。N 個の文字列を復号し、順に連結して 1 つの文字列として出力してください。

数字とモールス符号の対応は以下の通りです。

0 -----
1 .----
2 ..---
3 ...--
4 ....-
5 .....
6 -....
7 --...
8 ---..
9 ----.

制約

  • 1 \leq N \leq 100
  • N は整数
  • S_i (1 \leq i \leq N).- からなる文字列
  • S_i (1 \leq i \leq N)0 以上 9 以下のある数字に対応するモールス符号

入力

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

N
S_1
S_2
\vdots
S_N

出力

N 個の文字列を復号し、順に連結して 1 つの文字列として出力してください。


入力例 1

3
...--
.....
---..

出力例 1

358

...--3 と、.....5 と、---..8 と復号されます。よって、358 を出力します。


入力例 2

10
-----
.----
..---
...--
....-
.....
-....
--...
---..
----.

出力例 2

0123456789
E - Snuke the Cookie Picker

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 300

問題文

H マス, 横 W マスのグリッドがあります。上から i 行目、左から j 列目のマスを (i, j) と呼びます。
はじめ、グリッド上には、ある 縦横 2 マス以上 の部分長方形の内部にあるマスにクッキーが 1 枚ずつ置かれていて、それ以外のマスにはクッキーが置かれていません。
形式的に説明すると、以下の条件を全て満たす 4 つの整数の組 (a,b,c,d) がただ 1 つ存在します。

  • 1 \leq a \lt b \leq H
  • 1 \leq c \lt d \leq W
  • グリッド上のマスのうち、a \leq i \leq b, c \leq j \leq d を満たす全てのマス (i, j) にはクッキーが 1 枚ずつ置かれていて、それ以外のマスにはクッキーが置かれていない。

ところが、すぬけ君がグリッド上のクッキーのどれか 1 枚を取って食べてしまいました。
すぬけ君がクッキーを取ったマスは、クッキーが置かれていない状態に変わります。

すぬけ君がクッキーを食べた後のグリッドの状態が入力として与えられます。
マス (i, j) の状態は文字 S_{i,j} として与えられて、# はクッキーが置かれているマスを, . はクッキーが置かれていないマスを意味します。
すぬけ君が食べたクッキーが元々置かれていたマスを答えてください。(答えは一意に定まります。)

制約

  • 2 \leq H, W \leq 500
  • S_{i,j}# または .

入力

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

H W
S_{1,1}S_{1,2}\dotsS_{1,W}
S_{2,1}S_{2,2}\dotsS_{2,W}
\vdots
S_{H,1}S_{H,2}\dotsS_{H,W}

出力

すぬけ君が食べたクッキーが元々置かれていたマスを (i, j) とする。i, j をこの順に空白区切りで出力せよ。


入力例 1

5 6
......
..#.#.
..###.
..###.
......

出力例 1

2 4

はじめ、クッキーは (2, 3) を左上、(4, 5) を右下とする部分長方形の内部にあるマスに置かれていて、すぬけ君は (2, 4) にあるクッキーを食べたことがわかります。よって (2, 4) を出力します。


入力例 2

3 2
#.
##
##

出力例 2

1 2

はじめ、クッキーは (1, 1) を左上、(3, 2) を右下とする部分長方形の内部にあるマスに置かれていて、すぬけ君は (1, 2) にあるクッキーを食べたことがわかります。


入力例 3

6 6
..####
..##.#
..####
..####
..####
......

出力例 3

2 5

Score : 300 points

Problem Statement

There is a grid with H rows and W columns. Let (i, j) denote the square at the i-th row from the top and the j-th column from the left.
Initially, there was one cookie on each square inside a rectangle whose height and width were at least 2 squares long, and no cookie on the other squares.
Formally, there was exactly one quadruple of integers (a,b,c,d) that satisfied all of the following conditions.

  • 1 \leq a \lt b \leq H
  • 1 \leq c \lt d \leq W
  • There was one cookie on each square (i, j) such that a \leq i \leq b, c \leq j \leq d, and no cookie on the other squares.

However, Snuke took and ate one of the cookies on the grid.
The square that contained that cookie is now empty.

As the input, you are given the state of the grid after Snuke ate the cookie.
The state of the square (i, j) is given as the character S_{i,j}, where # means a square with a cookie, and . means a square without one.
Find the square that contained the cookie eaten by Snuke. (The answer is uniquely determined.)

Constraints

  • 2 \leq H, W \leq 500
  • S_{i,j} is # or ..

Input

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

H W
S_{1,1}S_{1,2}\dotsS_{1,W}
S_{2,1}S_{2,2}\dotsS_{2,W}
\vdots
S_{H,1}S_{H,2}\dotsS_{H,W}

Output

Let (i, j) the square contained the cookie eaten by Snuke. Print i and j in this order, separated by a space.


Sample Input 1

5 6
......
..#.#.
..###.
..###.
......

Sample Output 1

2 4

Initially, cookies were on the squares inside the rectangle with (2, 3) as the top-left corner and (4, 5) as the bottom-right corner, and Snuke ate the cookie on (2, 4). Thus, you should print (2, 4).


Sample Input 2

3 2
#.
##
##

Sample Output 2

1 2

Initially, cookies were placed on the squares inside the rectangle with (1, 1) as the top-left corner and (3, 2) as the bottom-right corner, and Snuke ate the cookie at (1, 2).


Sample Input 3

6 6
..####
..##.#
..####
..####
..####
......

Sample Output 3

2 5