実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 100 点
問題文
N 個の座席が並んでおり、座席には 1, 2, \ldots, N の番号が付けられています。
座席の状態は #, . からなる長さ N の文字列 S によって与えられます。S の i 文字目が # のとき座席 i には人が座っていることを表し、S の i 文字目が . のとき座席 i には人が座っていないことを表します。
1 以上 N - 2 以下の整数 i であって、以下の条件を満たすものの個数を求めてください。
- 座席 i, i + 2 には人が座っており、座席 i + 1 には人が座っていない
制約
- N は 1 以上 2 \times 10^5 以下の整数
- S は
#,.からなる長さ N の文字列
入力
入力は以下の形式で標準入力から与えられる。
N S
出力
答えを出力せよ。
入力例 1
6 #.##.#
出力例 1
2
i = 1, 4 が条件を満たすので、答えは 2 です。
入力例 2
1 #
出力例 2
0
入力例 3
9 ##.#.#.##
出力例 3
3
Score : 100 points
Problem Statement
There are N seats in a row, numbered 1, 2, \ldots, N.
The state of the seats is given by a string S of length N consisting of # and .. If the i-th character of S is #, it means seat i is occupied; if it is ., seat i is unoccupied.
Find the number of integers i between 1 and N - 2, inclusive, that satisfy the following condition:
- Seats i and i + 2 are occupied, and seat i + 1 is unoccupied.
Constraints
- N is an integer satisfying 1 \leq N \leq 2 \times 10^5.
- S is a string of length N consisting of
#and..
Input
The input is given from Standard Input in the following format:
N S
Output
Print the answer.
Sample Input 1
6 #.##.#
Sample Output 1
2
i = 1 and 4 satisfy the condition, so the answer is 2.
Sample Input 2
1 #
Sample Output 2
0
Sample Input 3
9 ##.#.#.##
Sample Output 3
3
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 150 点
問題文
AtCoder 王国の住民は A 時になるとたこ焼きへの愛を叫ぶことになっています。
AtCoder 王国に住む高橋君は毎日 B 時に就寝し C 時に起床します。高橋君は、起きているときはたこ焼きへの愛を叫ぶことができ、寝ているときは叫ぶことができません。高橋君が毎日たこ焼きへの愛を叫ぶことができているか判定してください。ただし、一日は 24 時間であり、高橋君が寝ている時間は 24 時間未満であるとします。
制約
- 0\leq A,B,C\lt 24
- A,B,C は相異なる
- 入力は全て整数
入力
入力は以下の形式で標準入力から与えられる。
A B C
出力
高橋君が毎日たこ焼きへの愛を叫ぶことができているならば Yes を、そうでないならば No を出力せよ。
入力例 1
21 8 14
出力例 1
Yes
高橋君は毎日 8 時に就寝し 14 時に起床します。21 時には起きているため、高橋君は毎日たこ焼きへの愛を叫ぶことができます。よって Yes を出力します。
入力例 2
0 21 7
出力例 2
No
高橋君は毎日 21 時に就寝し 7 時に起床します。0 時には起きていないため、高橋君は毎日たこ焼きへの愛を叫ぶことができません。よって No を出力します。
入力例 3
10 7 17
出力例 3
No
Score : 150 points
Problem Statement
In the Kingdom of AtCoder, residents are required to shout their love for takoyaki at A o'clock every day.
Takahashi, who lives in the Kingdom of AtCoder, goes to bed at B o'clock and wakes up at C o'clock every day (in the 24-hour clock). He can shout his love for takoyaki when he is awake, but cannot when he is asleep. Determine whether he can shout his love for takoyaki every day. Here, a day has 24 hours, and his sleeping time is less than 24 hours.
Constraints
- 0\leq A,B,C\lt 24
- A, B, and C are pairwise different.
- All input values are integers.
Input
The input is given from Standard Input in the following format:
A B C
Output
Print Yes if Takahashi can shout his love for takoyaki every day, and No otherwise.
Sample Input 1
21 8 14
Sample Output 1
Yes
Takahashi goes to bed at 8 o'clock and wakes up at 14 o'clock every day. He is awake at 21 o'clock, so he can shout his love for takoyaki every day. Therefore, print Yes.
Sample Input 2
0 21 7
Sample Output 2
No
Takahashi goes to bed at 21 o'clock and wakes up at 7 o'clock every day. He is not awake at 0 o'clock, so he cannot shout his love for takoyaki every day. Therefore, print No.
Sample Input 3
10 7 17
Sample Output 3
No
実行時間制限: 2 sec / メモリ制限: 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
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 200 点
問題文
長さ N の数列 A=(A_1,A_2,\dots,A_N) と、長さ M の数列 B=(B_1,B_2,\dots,B_M) が与えられます。ここで、A,B のすべての要素は互いに相異なります。A,B のすべての要素を昇順に並べた長さ N+M の数列 C=(C_1,C_2,\dots,C_{N+M}) において、A に現れる要素が2つ連続するかどうか判定してください。
制約
- 1\leq N,M \leq 100
- 1\leq A_i,B_j \leq 200
- A_1, A_2, \dots, A_N, B_1, B_2, \dots, B_M は相異なる
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N M A_1 A_2 \dots A_N B_1 B_2 \dots B_M
出力
A に現れる要素が C において2つ連続するならば Yes を、そうでないなら No を出力せよ。
入力例 1
3 2 3 2 5 4 1
出力例 1
Yes
C=(1,2,3,4,5) です。A に現れる 2,3 が C で連続しているため、Yes を出力します。
入力例 2
3 2 3 1 5 4 2
出力例 2
No
C=(1,2,3,4,5) です。A に現れる要素が C で連続している箇所はないため、No を出力します。
入力例 3
1 1 1 2
出力例 3
No
Score : 200 points
Problem Statement
You are given a sequence A=(A_1,A_2,\dots,A_N) of length N and a sequence B=(B_1,B_2,\dots,B_M) of length M. Here, all elements of A and B are pairwise distinct. Determine whether the sequence C=(C_1,C_2,\dots,C_{N+M}) formed by sorting all elements of A and B in ascending order contains two consecutive elements appearing in A.
Constraints
- 1 \leq N, M \leq 100
- 1 \leq A_i, B_j \leq 200
- A_1, A_2, \dots, A_N, B_1, B_2, \dots, B_M are distinct.
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N M A_1 A_2 \dots A_N B_1 B_2 \dots B_M
Output
If C contains two consecutive elements appearing in A, print Yes; otherwise, print No.
Sample Input 1
3 2 3 2 5 4 1
Sample Output 1
Yes
C=(1,2,3,4,5). Since 2 and 3 from A occur consecutively in C, print Yes.
Sample Input 2
3 2 3 1 5 4 2
Sample Output 2
No
C=(1,2,3,4,5). Since no two elements from A occur consecutively in C, print No.
Sample Input 3
1 1 1 2
Sample Output 3
No
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 300 点
問題文
列 S_n を次のように定義します。
- S_1 は 1 つの 1 からなる長さ 1 の列である。
- S_n (n は 2 以上の整数) は S_{n-1}, n, S_{n-1} をこの順につなげた列である。
たとえば S_2,S_3 は次のような列です。
- S_2 は S_1, 2, S_1 をこの順につなげた列なので 1,2,1 である。
- S_3 は S_2, 3, S_2 をこの順につなげた列なので 1,2,1,3,1,2,1 である。
N が与えられるので、列 S_N をすべて出力してください。
制約
- N は整数
- 1 \leq N \leq 16
入力
入力は以下の形式で標準入力から与えられる。
N
出力
S_N を空白区切りで出力せよ。
入力例 1
2
出力例 1
1 2 1
問題文の説明にある通り、S_2 は 1,2,1 となります。
入力例 2
1
出力例 2
1
入力例 3
4
出力例 3
1 2 1 3 1 2 1 4 1 2 1 3 1 2 1
S_4 は S_3,4,S_3 をこの順につなげた列です。
Score : 300 points
Problem Statement
We define sequences S_n as follows.
- S_1 is a sequence of length 1 containing a single 1.
- S_n (n is an integer greater than or equal to 2) is a sequence obtained by concatenating S_{n-1}, n, S_{n-1} in this order.
For example, S_2 and S_3 is defined as follows.
- S_2 is a concatenation of S_1, 2, and S_1, in this order, so it is 1,2,1.
- S_3 is a concatenation of S_2, 3, and S_2, in this order, so it is 1,2,1,3,1,2,1.
Given N, print the entire sequence S_N.
Constraints
- N is an integer.
- 1 \leq N \leq 16
Input
Input is given from Standard Input in the following format:
N
Output
Print S_N, with spaces in between.
Sample Input 1
2
Sample Output 1
1 2 1
As described in the Problem Statement, S_2 is 1,2,1.
Sample Input 2
1
Sample Output 2
1
Sample Input 3
4
Sample Output 3
1 2 1 3 1 2 1 4 1 2 1 3 1 2 1
- S_4 is a concatenation of S_3, 4, and S_3, in this order.