Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
ある日、高橋君は A 時 B 分ちょうどに、青木君は C 時 D 分 1 秒に起きました。
高橋君の起床時刻が青木君より早いならば Takahashi を、そうでないならば Aoki を出力してください。
制約
- 0 \leq A \leq 23
- 0 \leq B \leq 59
- 0 \leq C \leq 23
- 0 \leq D \leq 59
- 入力はすべて整数である。
入力
入力は以下の形式で標準入力から与えられる。
A B C D
出力
高橋君の起床時刻が青木君より早いならば Takahashi を、そうでないならば Aoki を出力せよ。
入力例 1
7 0 6 30
出力例 1
Aoki
高橋君は 7 時ちょうどに、青木君は 6 時 30 分 1 秒に起きました。
青木君の起床時刻の方が早いため、Aoki を出力します。
入力例 2
7 30 7 30
出力例 2
Takahashi
高橋君は 7 時 30 分ちょうどに、青木君は 7 時 30 分 1 秒に起きました。
高橋君の起床時刻の方が 1 秒だけ早いため、Takahashi を出力します。
入力例 3
0 0 23 59
出力例 3
Takahashi
ある日の 0 時 0 分ちょうどはその日の 0 時 1 分の 1 分前であり、
その日の 23 時 59 分の 1 分後、すなわちいわゆる 24 時ちょうどのことではありません。
よって、高橋君の起床時刻の方が早く、Takahashi を出力します。
Score : 100 points
Problem Statement
One day, Takahashi got up at exactly B minutes past A o'clock (in 24-hour clock), and Aoki got up at exactly D minutes and 1 second past C o'clock.
If Takahashi got up earlier than Aoki, print Takahashi; otherwise, print Aoki.
Constraints
- 0 \leq A \leq 23
- 0 \leq B \leq 59
- 0 \leq C \leq 23
- 0 \leq D \leq 59
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
A B C D
Output
If Takahashi got up earlier than Aoki, print Takahashi; otherwise, print Aoki.
Sample Input 1
7 0 6 30
Sample Output 1
Aoki
Takahashi got up at 7 sharp, and Aoki got up at 30 minutes and 1 second past 6 o'clock.
Aoki was the first to get up, so Aoki should be printed.
Sample Input 2
7 30 7 30
Sample Output 2
Takahashi
Takahashi got up at exactly half past 7, and Aoki got up at 30 minutes and 1 second past 7 o'clock.
Just by one second, Takahashi was the first to get up, so Takahashi should be printed.
Sample Input 3
0 0 23 59
Sample Output 3
Takahashi
0:00 in a day is one minute before 0:01, not one minute past 23:59 ("24:00").
Thus, Takahashi was the first to get up, so Takahashi should be printed.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 150 点
問題文
英小文字と | のみからなる文字列 S が与えられます。S は | をちょうど 2 個含むことが保証されます。
2 つの | の間にある文字および | を S から削除した文字列を出力してください。
制約
- S は英小文字および
|のみからなる長さ 2 以上 100 以下の文字列 - S は
|をちょうど 2 個含む
入力
入力は以下の形式で標準入力から与えられる。
S
出力
答えを出力せよ。
入力例 1
atcoder|beginner|contest
出力例 1
atcodercontest
2 つの | に挟まれた文字を全て削除して出力してください。
入力例 2
|spoiler|
出力例 2
全ての文字が削除されることもあります。
入力例 3
||xyz
出力例 3
xyz
Score: 150 points
Problem Statement
You are given a string S consisting of lowercase English letters and |. S is guaranteed to contain exactly two |s.
Remove the characters between the two |s, including the |s themselves, and print the resulting string.
Constraints
- S is a string of length between 2 and 100, inclusive, consisting of lowercase English letters and
|. - S contains exactly two
|s.
Input
The input is given from Standard Input in the following format:
S
Output
Print the answer.
Sample Input 1
atcoder|beginner|contest
Sample Output 1
atcodercontest
Remove all the characters between the two |s and print the result.
Sample Input 2
|spoiler|
Sample Output 2
It is possible that all characters are removed.
Sample Input 3
||xyz
Sample Output 3
xyz
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 150 点
問題文
文字列 T が以下の 3 つの条件をすべてみたすとき、かつそのときに限り、T を 1122 文字列 と呼びます。
- \lvert T \rvert は偶数である。ここで、\lvert T \rvert は T の長さを表す。
- 1\leq i\leq \frac{\lvert T \rvert}{2} をみたす整数 i について、T の (2i-1) 文字目と 2i 文字目は等しい。
- 各文字は T にちょうど 0 個または 2 個現れる。すなわち、T に含まれる文字は T にちょうど 2 回ずつ登場する。
英小文字のみからなる文字列 S が与えられるので、S が 1122 文字列であるならば Yes を、そうでないならば No を出力してください。
制約
- S は英小文字のみからなる長さ 1 以上 100 以下の文字列
入力
入力は以下の形式で標準入力から与えられる。
S
出力
S が 1122 文字列ならば Yes を、そうでないならば No を出力せよ。
入力例 1
aabbcc
出力例 1
Yes
S=aabbcc は 1122 文字列の条件をすべてみたしているため、Yes を出力します。
入力例 2
aab
出力例 2
No
S=aab は長さが奇数であり、 1 つめの条件をみたしていないため、No を出力します。
入力例 3
zzzzzz
出力例 3
No
S=zzzzzz は z が 6 個含まれており、 3 つめの条件をみたしていないため、No を出力します。
Score : 150 points
Problem Statement
A string T is called a 1122 string if and only if it satisfies all of the following three conditions:
- \lvert T \rvert is even. Here, \lvert T \rvert denotes the length of T.
- For each integer i satisfying 1\leq i\leq \frac{|T|}{2}, the (2i-1)-th and 2i-th characters of T are equal.
- Each character appears in T exactly zero or two times. That is, every character contained in T appears exactly twice in T.
Given a string S consisting of lowercase English letters, print Yes if S is a 1122 string, and No otherwise.
Constraints
- S is a string of length between 1 and 100, inclusive, consisting of lowercase English letters.
Input
The input is given from Standard Input in the following format:
S
Output
If S is a 1122 string, print Yes; otherwise, print No.
Sample Input 1
aabbcc
Sample Output 1
Yes
S=aabbcc satisfies all the conditions for a 1122 string, so print Yes.
Sample Input 2
aab
Sample Output 2
No
S=aab has an odd length and does not satisfy the first condition, so print No.
Sample Input 3
zzzzzz
Sample Output 3
No
S=zzzzzz contains six zs and does not satisfy the third condition, so print No.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 150 点
問題文
実数 X が小数点以下第 3 位まで与えられます。
実数 X を以下の条件を満たすように出力してください。
- 小数点以下の部分について、末尾に
0を付けない - 末尾に過剰な小数点を付けない
制約
- 0 \le X < 100
- X は小数点以下第 3 位まで与えられる
入力
入力は以下の形式で標準入力から与えられる。
X
出力
答えを出力せよ。
入力例 1
1.012
出力例 1
1.012
1.012 はそのまま出力しても構いません。
入力例 2
12.340
出力例 2
12.34
12.340 を末尾に 0 を付けずに出力すると 12.34 となります。
入力例 3
99.900
出力例 3
99.9
99.900 を末尾に 0 を付けずに出力すると 99.9 となります。
入力例 4
0.000
出力例 4
0
0.000 を末尾に 0 や過剰な小数点を付けずに出力すると 0 となります。
Score : 150 points
Problem Statement
A real number X is given to the third decimal place.
Print the real number X under the following conditions.
- The decimal part must not have trailing
0s. - There must not be an unnecessary trailing decimal point.
Constraints
- 0 \le X < 100
- X is given to the third decimal place.
Input
The input is given from Standard Input in the following format:
X
Output
Output the answer.
Sample Input 1
1.012
Sample Output 1
1.012
1.012 can be printed as it is.
Sample Input 2
12.340
Sample Output 2
12.34
Printing 12.340 without the trailing 0 results in 12.34.
Sample Input 3
99.900
Sample Output 3
99.9
Printing 99.900 without the trailing 0s results in 99.9.
Sample Input 4
0.000
Sample Output 4
0
Printing 0.000 without trailing 0s or an unnecessary decimal point results in 0.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 300 点
問題文
10^9 行 10^9 列のグリッドがあり、このグリッドの上から i 番目、左から j 番目のマスをマス (i, j) と表記します。
グリッド上には N 人の人がおり、はじめ i 人目の人はマス (R_i, C_i) にいます。
はじめ時刻は 0 であり、各人は、時刻 1, 2, 3, 4, \ldots に以下のような移動をすることができます。
- その場に留まるか、8 近傍のマスに移動する。ただし、グリッドの外側に出ることはできない。厳密には、現在いるマスをマス (i, j) としてマス (i - 1, j - 1), (i - 1, j), (i - 1, j + 1), (i, j - 1), (i, j), (i, j + 1), (i + 1, j - 1), (i + 1, j), (i + 1, j + 1) のうち存在するマスのいずれかに移動する。また、移動には時間がかからないものとする。
N 人の人が全員同じマスに集まる時刻として考えられる最小値を求めてください。
制約
- 1 \leq N \leq 2 \times 10^5
- 1 \leq R_i, C_i \leq 10^9
- 入力される値はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N R_1 C_1 R_2 C_2 \vdots R_N C_N
出力
答えを出力せよ。
入力例 1
3 2 3 5 1 8 1
出力例 1
3
以下のようにそれぞれの人が移動することによって、全員が時刻 3 にマス (5, 4) に集まります。
-
時刻 1 では、1 人目の人はマス (3, 4)、2 人目の人はマス (6, 2)、3 人目の人はマス (7, 2) に移動する。
-
時刻 2 では、1 人目の人はマス (4, 4)、2 人目の人はマス (5, 3)、3 人目の人はマス (6, 3) に移動する。
-
時刻 3 では、1 人目の人はマス (5, 4)、2 人目の人はマス (5, 4)、3 人目の人はマス (5, 4) に移動する。
入力例 2
5 6 7 6 7 6 7 6 7 6 7
出力例 2
0
はじめからすべての人は同じマスにいます。
入力例 3
6 91 999999986 53 999999997 32 999999932 14 999999909 49 999999985 28 999999926
出力例 3
44
Score : 300 points
Problem Statement
There is a grid with 10^9 rows and 10^9 columns. Let (i, j) denote the square at the i-th row from the top and j-th column from the left.
There are N people on the grid. Initially, the i-th person is at square (R_i, C_i).
The time starts at 0. Each person can do the following move at times 1, 2, 3, 4, \ldots.
- Stay at the current position, or move to an 8-adjacent square. It is forbidden to leave the grid. Formally, let square (i, j) be the current square, and move to one of the squares (i - 1, j - 1), (i - 1, j), (i - 1, j + 1), (i, j - 1), (i, j), (i, j + 1), (i + 1, j - 1), (i + 1, j), (i + 1, j + 1) that exists. Assume that the move takes no time.
Find the minimum possible time when the N people are at the same square.
Constraints
- 1 \leq N \leq 2 \times 10^5
- 1 \leq R_i, C_i \leq 10^9
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N R_1 C_1 R_2 C_2 \vdots R_N C_N
Output
Output the answer.
Sample Input 1
3 2 3 5 1 8 1
Sample Output 1
3
All people will be at square (5, 4) at time 3 if each person moves as follows.
-
At time 1, the 1st person moves to square (3, 4), the 2nd person moves to square (6, 2), and the 3rd person moves to square (7, 2).
-
At time 2, the 1st person moves to square (4, 4), the 2nd person moves to square (5, 3), and the 3rd person moves to square (6, 3).
-
At time 3, the 1st person moves to square (5, 4), the 2nd person moves to square (5, 4), and the 3rd person moves to square (5, 4).
Sample Input 2
5 6 7 6 7 6 7 6 7 6 7
Sample Output 2
0
All people start at the same square.
Sample Input 3
6 91 999999986 53 999999997 32 999999932 14 999999909 49 999999985 28 999999926
Sample Output 3
44