Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
長さ N の数列 A = (A_1, A_2, \dots, A_N) が与えられます。
あなたは次の操作をちょうど K 回行います。
- A の先頭の要素を取り除き、A の末尾に 0 を挿入する。
操作を行った後の A の要素をすべて出力してください。
制約
- 1 \leq N \leq 100
- 1 \leq K \leq 100
- 1 \leq A_i \leq 100
- 入力される値はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N K A_1 A_2 \dots A_N
出力
操作を行った後の A の要素を空白区切りで 1 行に出力せよ。
入力例 1
3 2 2 7 8
出力例 1
8 0 0
操作を行う前は A = (2, 7, 8) です。
操作を 1 回行った時点では A = (7, 8, 0) です。
操作を 2 回行った時点では A = (8, 0, 0) です。
よって (8, 0, 0) が答えです。
入力例 2
3 4 9 9 9
出力例 2
0 0 0
入力例 3
9 5 1 2 3 4 5 6 7 8 9
出力例 3
6 7 8 9 0 0 0 0 0
Score : 100 points
Problem Statement
You are given a sequence A = (A_1, A_2, \dots, A_N) of length N.
You perform the following operation exactly K times:
- remove the initial element of A and append a 0 to the tail of A.
Print all the elements of A after the operations.
Constraints
- 1 \leq N \leq 100
- 1 \leq K \leq 100
- 1 \leq A_i \leq 100
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
N K A_1 A_2 \dots A_N
Output
Print the elements of A after the operations in one line, separated by spaces.
Sample Input 1
3 2 2 7 8
Sample Output 1
8 0 0
Before the operations, A = (2, 7, 8).
After performing the operation once, A = (7, 8, 0).
After performing the operation twice, A = (8, 0, 0).
Thus, (8, 0, 0) is the answer.
Sample Input 2
3 4 9 9 9
Sample Output 2
0 0 0
Sample Input 3
9 5 1 2 3 4 5 6 7 8 9
Sample Output 3
6 7 8 9 0 0 0 0 0
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
高橋君は
2025 年 5 月 17 日 A 時 B 分締切のレポートを、
2025 年 5 月 17 日 C 時 D 分に提出しました。
ここで、「A 時 B 分」と「C 時 D 分」は異なる時刻であることが保証されます。
高橋君が締切前にレポートを提出しているならば Yes を、そうでないならば No を出力してください。
制約
- 0 \leq A,C \leq 23
- 0 \leq B,D \leq 59
- (A,B)\neq(C,D)
- A,B,C,D は整数
入力
入力は以下の形式で標準入力から与えられる。
A B C D
出力
高橋君が締切前にレポートを提出しているならば Yes を、そうでないならば No を出力せよ。
入力例 1
22 40 22 30
出力例 1
Yes
レポートの締切は 22 時 40 分であり、高橋君は 22 時 30 分に提出しているため、締切前にレポートを提出しています。
よって、Yes を出力します。
入力例 2
22 40 22 45
出力例 2
No
レポートの締切は 22 時 40 分であり、高橋君は 22 時 45 分に提出しているため、締切後にレポートを提出しています。
よって、No を出力します。
入力例 3
12 0 11 30
出力例 3
Yes
Score : 100 points
Problem Statement
Takahashi had a report whose deadline was B minutes past A o'clock on May 17, 2025. He submitted it at D minutes past C o'clock on May 17, 2025.
It is guaranteed that "B minutes past A o'clock" and "D minutes past C o'clock" are different times.
Output Yes if Takahashi submitted the report before the deadline, and No otherwise.
Constraints
- 0 \leq A, C \leq 23
- 0 \leq B, D \leq 59
- (A, B) \neq (C, D)
- A, B, C, and D are integers.
Input
The input is given from Standard Input in the following format:
A B C D
Output
If Takahashi submitted the report before the deadline, output Yes; otherwise, output No.
Sample Input 1
22 40 22 30
Sample Output 1
Yes
The deadline is 22:40, and he submitted at 22:30, so he submitted before the deadline.
Hence, output Yes.
Sample Input 2
22 40 22 45
Sample Output 2
No
The deadline is 22:40, and he submitted at 22:45, so he submitted after the deadline.
Hence, output No.
Sample Input 3
12 0 11 30
Sample Output 3
Yes
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
高橋君には、穴 1,2,\dots,N に 1 本ずつ、全部で N 本の歯が生えています。
歯医者の青木君は、これらの歯と穴に対して、 Q 回の治療を行います。
i 回目の治療では、穴 T_i を治療します。治療内容は次の通りです。
- 穴 T_i に歯が生えている場合、穴 T_i から歯を抜く。
- そうでない ( 穴 T_i に歯が生えていない) 場合、穴 T_i に歯を生やす。
全ての治療が終わった後、高橋君に生えている歯の本数は何本ですか?
制約
- 入力は全て整数
- 1 \le N,Q \le 1000
- 1 \le T_i \le N
入力
入力は以下の形式で標準入力から与えられる。
N Q T_1 T_2 \dots T_Q
出力
答えを整数として出力せよ。
入力例 1
30 6 2 9 18 27 18 9
出力例 1
28
高橋君には最初 30 本の歯が生えており、青木君は 6 回の治療を行います。
- 1 回目の治療では穴 2 を治療します。 穴 2 に歯が生えているため、歯を抜きます。
- 2 回目の治療では穴 9 を治療します。 穴 9 に歯が生えているため、歯を抜きます。
- 3 回目の治療では穴 18 を治療します。 穴 18 に歯が生えているため、歯を抜きます。
- 4 回目の治療では穴 27 を治療します。 穴 27 に歯が生えているため、歯を抜きます。
- 5 回目の治療では穴 18 を治療します。 穴 18 に歯が生えていないため、歯を生やします。
- 6 回目の治療では穴 9 を治療します。 穴 9 に歯が生えていないため、歯を生やします。
最終的な歯の本数は 28 本です。
入力例 2
1 7 1 1 1 1 1 1 1
出力例 2
0
入力例 3
9 20 9 5 1 2 2 2 8 9 2 1 6 2 6 5 8 7 8 5 9 8
出力例 3
5
Score: 200 points
Problem Statement
Takahashi has N teeth, one in each of the holes numbered 1, 2, \dots, N.
Dentist Aoki will perform Q treatments on these teeth and holes.
In the i-th treatment, hole T_i is treated as follows:
- If there is a tooth in hole T_i, remove the tooth from hole T_i.
- If there is no tooth in hole T_i (i.e., the hole is empty), grow a tooth in hole T_i.
After all treatments are completed, how many teeth does Takahashi have?
Constraints
- All input values are integers.
- 1 \le N, Q \le 1000
- 1 \le T_i \le N
Input
The input is given from Standard Input in the following format:
N Q T_1 T_2 \dots T_Q
Output
Print the number of teeth as an integer.
Sample Input 1
30 6 2 9 18 27 18 9
Sample Output 1
28
Initially, Takahashi has 30 teeth, and Aoki performs six treatments.
- In the first treatment, hole 2 is treated. There is a tooth in hole 2, so it is removed.
- In the second treatment, hole 9 is treated. There is a tooth in hole 9, so it is removed.
- In the third treatment, hole 18 is treated. There is a tooth in hole 18, so it is removed.
- In the fourth treatment, hole 27 is treated. There is a tooth in hole 27, so it is removed.
- In the fifth treatment, hole 18 is treated. There is no tooth in hole 18, so a tooth is grown.
- In the sixth treatment, hole 9 is treated. There is no tooth in hole 9, so a tooth is grown.
The final count of teeth is 28.
Sample Input 2
1 7 1 1 1 1 1 1 1
Sample Output 2
0
Sample Input 3
9 20 9 5 1 2 2 2 8 9 2 1 6 2 6 5 8 7 8 5 9 8
Sample Output 3
5
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
x 軸の正の向きが右、y 軸の正の向きが上であるような xy 座標平面において、点 (a,b) を原点を中心として反時計回りに d 度回転させた点を求めてください。
制約
- -1000 \leq a,b \leq 1000
- 1 \leq d \leq 360
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
a b d
出力
求めるべき点を (a',b') とするとき、 a' と b' をこの順に空白区切りで出力せよ。
なお、各出力について、解との絶対誤差または相対誤差が 10^{−6} 以下であれば正解として扱われる。
入力例 1
2 2 180
出力例 1
-2 -2
(2,2) を原点を中心として反時計回りに 180 度回転させた点は、(2,2) を原点について対称な位置に移動させた点であり、(-2,-2) となります。
入力例 2
5 0 120
出力例 2
-2.49999999999999911182 4.33012701892219364908
(5,0) を原点を中心として反時計回りに 120 度回転させた点は (-\frac {5}{2} , \frac {5\sqrt{3}}{2}) です。
この例での出力はこれらの値と厳密には一致しませんが、誤差が十分に小さいため正解として扱われます。
入力例 3
0 0 11
出力例 3
0.00000000000000000000 0.00000000000000000000
(a,b) が原点(回転の中心)なので回転させても座標が変わりません。
入力例 4
15 5 360
出力例 4
15.00000000000000177636 4.99999999999999555911
360 度回転させたので座標が変わりません。
入力例 5
-505 191 278
出力例 5
118.85878514480690171240 526.66743699786547949770
Score : 200 points
Problem Statement
In an xy-coordinate plane whose x-axis is oriented to the right and whose y-axis is oriented upwards, rotate a point (a, b) around the origin d degrees counterclockwise and find the new coordinates of the point.
Constraints
- -1000 \leq a,b \leq 1000
- 1 \leq d \leq 360
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
a b d
Output
Let the new coordinates of the point be (a', b'). Print a' and b' in this order, with a space in between.
Your output will be considered correct when, for each value printed, the absolute or relative error from the answer is at most 10^{-6}.
Sample Input 1
2 2 180
Sample Output 1
-2 -2
When (2, 2) is rotated around the origin 180 degrees counterclockwise, it becomes the symmetric point of (2, 2) with respect to the origin, which is (-2, -2).
Sample Input 2
5 0 120
Sample Output 2
-2.49999999999999911182 4.33012701892219364908
When (5, 0) is rotated around the origin 120 degrees counterclockwise, it becomes (-\frac {5}{2} , \frac {5\sqrt{3}}{2}).
This sample output does not precisely match these values, but the errors are small enough to be considered correct.
Sample Input 3
0 0 11
Sample Output 3
0.00000000000000000000 0.00000000000000000000
Since (a, b) is the origin (the center of rotation), a rotation does not change its coordinates.
Sample Input 4
15 5 360
Sample Output 4
15.00000000000000177636 4.99999999999999555911
A 360-degree rotation does not change the coordinates of a point.
Sample Input 5
-505 191 278
Sample Output 5
118.85878514480690171240 526.66743699786547949770
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 300 点
問題文
2 つの文字列 A,B に対して、A の末尾に B を連結した文字列を A+B と表します。
N 個の文字列 S_1,\ldots,S_N が与えられます。i=1,\ldots,N の順に、次の指示に従って加工して出力してください。
- S_1,\ldots,S_{i-1} の中に S_i と同じ文字列が存在しないならば、S_i を出力する。
- S_1,\ldots,S_{i-1} の中に S_i と同じ文字列が X 個 (X>0) 存在するならば、X を文字列として扱って S_i+
(+X+)を出力する。
制約
- 1 \leq N \leq 2\times 10^5
- S_i は英小文字のみからなる長さ 1 以上 10 以下の文字列
入力
入力は以下の形式で標準入力から与えられる。
N S_1 S_2 \vdots S_N
出力
問題文中の指示にしたがって、N 行出力せよ。
入力例 1
5 newfile newfile newfolder newfile newfolder
出力例 1
newfile newfile(1) newfolder newfile(2) newfolder(1)
入力例 2
11 a a a a a a a a a a a
出力例 2
a a(1) a(2) a(3) a(4) a(5) a(6) a(7) a(8) a(9) a(10)
Score : 300 points
Problem Statement
For two strings A and B, let A+B denote the concatenation of A and B in this order.
You are given N strings S_1,\ldots,S_N. Modify and print them as follows, in the order i=1, \ldots, N:
- if none of S_1,\ldots,S_{i-1} is equal to S_i, print S_i;
- if X (X>0) of S_1,\ldots,S_{i-1} are equal to S_i, print S_i+
(+X+), treating X as a string.
Constraints
- 1 \leq N \leq 2\times 10^5
- S_i is a string of length between 1 and 10 (inclusive) consisting of lowercase English letters.
Input
Input is given from Standard Input in the following format:
N S_1 S_2 \vdots S_N
Output
Print N lines as specified in the Problem Statement.
Sample Input 1
5 newfile newfile newfolder newfile newfolder
Sample Output 1
newfile newfile(1) newfolder newfile(2) newfolder(1)
Sample Input 2
11 a a a a a a a a a a a
Sample Output 2
a a(1) a(2) a(3) a(4) a(5) a(6) a(7) a(8) a(9) a(10)