実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 100 点
問題文
英大文字からなる文字列 S が与えられます。S の各文字を空白で区切り、その順で 1 文字ずつ出力してください。
制約
- S は長さ 2 以上 100 以下の英大文字からなる文字列
入力
入力は以下の形式で標準入力から与えられる。
S
出力
S の各文字を空白で区切り、1 文字ずつ出力せよ。
入力例 1
ABC
出力例 1
A B C
A, B, C を空白で区切り、1 文字ずつ出力してください。
C の後ろに空白を出力する必要がないことに注意してください。
入力例 2
ZZZZZZZ
出力例 2
Z Z Z Z Z Z Z
入力例 3
OOXXOO
出力例 3
O O X X O O
Score : 100 points
Problem Statement
You are given a string S consisting of uppercase English letters. Separate each character of S with a space and print them one by one in order.
Constraints
- S is a string consisting of uppercase English letters with a length between 2 and 100, inclusive.
Input
The input is given from Standard Input in the following format:
S
Output
Separate each character of S with a space and print them one by one.
Sample Input 1
ABC
Sample Output 1
A B C
Separate A, B, and C with spaces and print them one by one.
There is no need to print a space after C.
Sample Input 2
ZZZZZZZ
Sample Output 2
Z Z Z Z Z Z Z
Sample Input 3
OOXXOO
Sample Output 3
O O X X O O
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 100 点
問題文
野球少年の高橋君は今年とても良い子にしていたので、サンタさんはバットかグローブのうち値段が高い方を高橋君にプレゼントすることにしました。
バットの値段が B 円、グローブの値段が G 円 (B\neq G) のとき、サンタさんが高橋君にプレゼントするのはどちらですか?
制約
- B,G は 1 以上 1000 以下の相異なる整数
入力
入力は以下の形式で標準入力から与えられる。
B G
出力
サンタさんが高橋君にプレゼントするのがバットであるとき Bat を、グローブであるとき Glove を出力せよ。
入力例 1
300 100
出力例 1
Bat
バットの方がグローブより値段が高いので、サンタさんは高橋君にバットをプレゼントします。
入力例 2
334 343
出力例 2
Glove
グローブの方がバットより値段が高いので、サンタさんは高橋君にグローブをプレゼントします。
Score : 100 points
Problem Statement
Takahashi, a young baseball enthusiast, has been a very good boy this year, so Santa has decided to give him a bat or a glove, whichever is more expensive.
If a bat costs B yen and a glove costs G yen (B\neq G), which one will Santa give to Takahashi?
Constraints
- B and G are different integers between 1 and 1000, inclusive.
Input
The input is given from Standard Input in the following format:
B G
Output
If Santa gives Takahashi a bat, print Bat; if Santa gives him a glove, print Glove.
Sample Input 1
300 100
Sample Output 1
Bat
The bat is more expensive than the glove, so Santa will give Takahashi the bat.
Sample Input 2
334 343
Sample Output 2
Glove
The glove is more expensive than the bat, so Santa will give Takahashi the glove.
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 200 点
問題文
正整数 N が与えられるので、下記で定まる長さ (N+1) の文字列 s_0s_1\ldots s_N を出力してください。
各 i = 0, 1, 2, \ldots, N について、
- 1 以上 9 以下の N の約数 j であって、i が N/j の倍数であるものが存在するとき、そのような j のうち最小のものに対応する数字を s_i とする。(よって、この場合 s_i は
1、2、\ldots 、9のいずれかである。)- そのような j が存在しないとき、s_i は
-とする。
制約
- 1 \leq N \leq 1000
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N
出力
答えを出力せよ。
入力例 1
12
出力例 1
1-643-2-346-1
以下で、いくつかの i について s_i の決め方を説明します。
-
i = 0 について、1 以上 9 以下の N の約数 j であって i が N/j の倍数であるものは、j = 1, 2, 3, 4, 6 の 5 個です。そのうち最小のものは 1 であるので、s_0 =
1です。 -
i = 4 について、1 以上 9 以下の N の約数 j であって i が N/j の倍数であるものは、j = 3, 6 の 2 個です。そのうち最小のものは 3 であるので、s_4 =
3です。 -
i = 11 について、1 以上 9 以下の N の約数 j であって i が N/j の倍数であるものは存在しないので、s_{11} =
-です。
入力例 2
7
出力例 2
17777771
入力例 3
1
出力例 3
11
Score : 200 points
Problem Statement
You are given a positive integer N. Print a string of length (N+1), s_0s_1\ldots s_N, defined as follows.
For each i = 0, 1, 2, \ldots, N,
- if there is a divisor j of N that is between 1 and 9, inclusive, and i is a multiple of N/j, then s_i is the digit corresponding to the smallest such j (s_i will thus be one of
1,2, ...,9);- if no such j exists, then s_i is
-.
Constraints
- 1 \leq N \leq 1000
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N
Output
Print the answer.
Sample Input 1
12
Sample Output 1
1-643-2-346-1
We will explain how to determine s_i for some i.
-
For i = 0, the divisors j of N between 1 and 9 such that i is a multiple of N/j are 1, 2, 3, 4, 6. The smallest of these is 1, so s_0 =
1. -
For i = 4, the divisors j of N between 1 and 9 such that i is a multiple of N/j are 3, 6. The smallest of these is 3, so s_4 =
3. -
For i = 11, there are no divisors j of N between 1 and 9 such that i is a multiple of N/j, so s_{11} =
-.
Sample Input 2
7
Sample Output 2
17777771
Sample Input 3
1
Sample Output 3
11
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 200 点
問題文
高橋くんは、以下の方法で 10 個の文字列 S_1,S_2,\dots,S_{10} を生成しました。
- まず、 S_i (1 \le i \le 10)=
..........(.が 10 個並んだ文字列) とする。 - 次に、以下の条件を全て満たす 4 つの整数 A,B,C,D を選ぶ。
- 1 \le A \le B \le 10
- 1 \le C \le D \le 10
- その後、以下の条件を全て満たす全ての整数組 (i,j) について、 S_i の j 文字目を
#に書き換える。- A \le i \le B
- C \le j \le D
以上の方法で生成された S_1,S_2,\dots,S_{10} が与えられるので、高橋くんが選んだ整数 A,B,C,D を求めてください。
なお、制約より A,B,C,D は一意に定まる (答えはただひとつ存在する) ことが証明できます。
制約
- S_1,S_2,\dots,S_{10} は問題文中の方法で生成されうるそれぞれ長さ 10 の文字列
入力
入力は以下の形式で標準入力から与えられる。
S_1
S_2
\vdots
S_{10}
出力
答えを以下の形式で出力せよ。
A B C D
入力例 1
.......... .......... .......... .......... ...######. ...######. ...######. ...######. .......... ..........
出力例 1
5 8 4 9
高橋くんが選んだ整数は A=5,B=8,C=4,D=9 です。
このように選ぶことにより、 S_5,S_6,S_7,S_8 の 4 文字目から 9 文字目が # であり他の文字が . である 10 個の長さ 10 の文字列 S_1,S_2,\dots,S_{10} が生成されます。
これは入力で与えられた 10 個の文字列と一致します。
入力例 2
.......... ..#....... .......... .......... .......... .......... .......... .......... .......... ..........
出力例 2
2 2 3 3
入力例 3
########## ########## ########## ########## ########## ########## ########## ########## ########## ##########
出力例 3
1 10 1 10
Score : 200 points
Problem Statement
Takahashi generated 10 strings S_1,S_2,\dots,S_{10} as follows.
- First, let S_i (1 \le i \le 10)=
..........(10.s in a row). - Next, choose four integers A, B, C, and D satisfying all of the following.
- 1 \le A \le B \le 10.
- 1 \le C \le D \le 10.
- Then, for every pair of integers (i,j) satisfying all of the following, replace the j-th character of S_i with
#.- A \le i \le B.
- C \le j \le D.
You are given S_1,S_2,\dots,S_{10} generated as above. Find the integers A, B, C, and D Takahashi chose.
It can be proved that such integers A, B, C, and D uniquely exist (there is just one answer) under the Constraints.
Constraints
- S_1,S_2,\dots,S_{10} are strings, each of length 10, that can be generated according to the Problem Statement.
Input
The input is given from Standard Input in the following format:
S_1
S_2
\vdots
S_{10}
Output
Print the answer in the following format:
A B C D
Sample Input 1
.......... .......... .......... .......... ...######. ...######. ...######. ...######. .......... ..........
Sample Output 1
5 8 4 9
Here, Takahashi chose A=5, B=8, C=4, D=9.
This choice generates 10 strings S_1,S_2,\dots,S_{10}, each of length 10, where the 4-th through 9-th characters of S_5,S_6,S_7,S_8 are #, and the other characters are ..
These are equal to the strings given in the input.
Sample Input 2
.......... ..#....... .......... .......... .......... .......... .......... .......... .......... ..........
Sample Output 2
2 2 3 3
Sample Input 3
########## ########## ########## ########## ########## ########## ########## ########## ########## ##########
Sample Output 3
1 10 1 10
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 300 点
問題文
人 1, 人 2,\ldots, 人 N の N 人が一列に並んでいます。
並び方の情報が長さ N の数列 A=(A _ 1,A _ 2,\ldots,A _ N) として与えられます。
A _ i\ (1\leq i\leq N) は次のような情報を表しています。
- A _ i=-1 のとき、人 i は先頭に並んでいる。
- A _ i\neq -1 のとき、人 i は人 A _ i のすぐ後ろに並んでいる。
列に並んでいる人の番号を先頭から順番に出力してください。
制約
- 1\leq N\leq3\times10 ^ 5
- A _ i=-1 もしくは 1\leq A _ i\leq N\ (1\leq i\leq N)
- 情報と矛盾しないような N 人の並び方がただ 1 通り存在する
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N A _ 1 A _ 2 \ldots A _ N
出力
人 s _ 1, 人 s _ 2,\ldots, 人 s _ N がこの順に列に並んでいるとき、s _ 1,s _ 2,\ldots,s _ N をこの順に空白を区切りとして出力せよ。
入力例 1
6 4 1 -1 5 3 2
出力例 1
3 5 4 1 2 6
先頭から、人 3, 人 5, 人 4, 人 1, 人 2, 人 6 がこの順に列に並んでいるとき、与えられた情報と一致しています。
実際、
- 人 1 は人 4 のすぐ後ろに並んでいます。
- 人 2 は人 1 のすぐ後ろに並んでいます。
- 人 3 は先頭に並んでいます。
- 人 4 は人 5 のすぐ後ろに並んでいます。
- 人 5 は人 3 のすぐ後ろに並んでいます。
- 人 6 は人 2 のすぐ後ろに並んでいます。
となり、与えられた情報と一致していることが確認できます。
よって、3,5,4,1,2,6 をこの順に空白区切りで出力してください。
入力例 2
10 -1 1 2 3 4 5 6 7 8 9
出力例 2
1 2 3 4 5 6 7 8 9 10
入力例 3
30 3 25 20 6 18 12 26 1 29 -1 21 17 23 9 8 30 10 15 22 27 4 13 5 11 16 24 28 2 19 7
出力例 3
10 17 12 6 4 21 11 24 26 7 30 16 25 2 28 27 20 3 1 8 15 18 5 23 13 22 19 29 9 14
Score: 300 points
Problem Statement
There are N people standing in a line: person 1, person 2, \ldots, person N.
You are given the arrangement of the people as a sequence A=(A _ 1,A _ 2,\ldots,A _ N) of length N.
A _ i\ (1\leq i\leq N) represents the following information:
- if A _ i=-1, person i is at the front of the line;
- if A _ i\neq -1, person i is right behind person A _ i.
Print the people's numbers in the line from front to back.
Constraints
- 1\leq N\leq3\times10 ^ 5
- A _ i=-1 or 1\leq A _ i\leq N\ (1\leq i\leq N)
- There is exactly one way to arrange the N people consistent with the information given.
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N A _ 1 A _ 2 \ldots A _ N
Output
If person s _ 1, person s _ 2, \ldots, person s _ N are standing in the line in this order, print s _ 1, s _ 2, \ldots, and s _ N in this order, separated by spaces.
Sample Input 1
6 4 1 -1 5 3 2
Sample Output 1
3 5 4 1 2 6
If person 3, person 5, person 4, person 1, person 2, and person 6 stand in line in this order from front to back, the arrangement matches the given information.
Indeed, it can be seen that:
- person 1 is standing right behind person 4,
- person 2 is standing right behind person 1,
- person 3 is at the front of the line,
- person 4 is standing right behind person 5,
- person 5 is standing right behind person 3, and
- person 6 is standing right behind person 2.
Thus, print 3, 5, 4, 1, 2, and 6 in this order, separated by spaces.
Sample Input 2
10 -1 1 2 3 4 5 6 7 8 9
Sample Output 2
1 2 3 4 5 6 7 8 9 10
Sample Input 3
30 3 25 20 6 18 12 26 1 29 -1 21 17 23 9 8 30 10 15 22 27 4 13 5 11 16 24 28 2 19 7
Sample Output 3
10 17 12 6 4 21 11 24 26 7 30 16 25 2 28 27 20 3 1 8 15 18 5 23 13 22 19 29 9 14