実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 100 点
問題文
面積が正である三角形 ABC があります。
三角形 ABC の三辺の長さはそれぞれ a,b,c です。
三角形 ABC が二等辺三角形であるか判定してください。
制約
- 1 \leq a,b,c \leq 10
- 三辺の長さが a,b,c であるような三角形が存在し、その面積は正である。
- a,b,c は整数
入力
入力は以下の形式で標準入力から与えられる。
a b c
出力
三角形 ABC が二等辺三角形であるならば Yes を、そうでないならば No を出力せよ。
入力例 1
4 2 4
出力例 1
Yes
a=c であるため、三角形 ABC は二等辺三角形です。
よって、Yes を出力します。
入力例 2
3 4 5
出力例 2
No
三角形 ABC の三辺の長さはすべて異なるため、二等辺三角形ではありません。
よって、No を出力します。
入力例 3
10 10 10
出力例 3
Yes
正三角形も二等辺三角形の一種であることに注意してください。
Score : 100 points
Problem Statement
There is a triangle ABC with positive area.
The lengths of the three sides of triangle ABC are a,b,c.
Determine whether triangle ABC is isosceles.
Constraints
- 1 \leq a,b,c \leq 10
- A triangle with side lengths a,b,c exists, and its area is positive.
- a,b,c are integers.
Input
The input is given from Standard Input in the following format:
a b c
Output
If triangle ABC is isosceles, output Yes; otherwise, output No.
Sample Input 1
4 2 4
Sample Output 1
Yes
Since a=c, triangle ABC is isosceles.
Thus, output Yes.
Sample Input 2
3 4 5
Sample Output 2
No
Since the three side lengths of triangle ABC are all different, it is not isosceles.
Thus, output No.
Sample Input 3
10 10 10
Sample Output 3
Yes
Note that an equilateral triangle is a kind of isosceles triangle.
実行時間制限: 2 sec / メモリ制限: 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
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 200 点
問題文
縦 R 行横 C 列の盤面があります。上から i 行目、左から j 列目のマスを (i,j) と表します。
(i,j) の現在の状態が文字 B_{i,j} として与えられます。
. は空きマス、# は壁があるマスを表し、
1, 2,\dots, 9 はそれぞれ威力 1,2,\dots,9 の爆弾があるマスを表します。
次の瞬間に、全ての爆弾が同時に爆発します。 爆弾が爆発すると、爆弾があるマスからのマンハッタン距離がその爆弾の威力以下であるような全てのマス(その爆弾があるマス自体を含む)が空きマスに変わります。 ここで、(r_1,c_1) から (r_2,c_2) までのマンハッタン距離は |r_1-r_2|+|c_1-c_2| です。
爆発後の盤面を出力してください。
制約
- 1\leq R,C \leq 20
- R,C は整数
- B_{i,j} は
.,#,1,2,\dots,9のいずれかである
入力
入力は以下の形式で標準入力から与えられる。
R C
B_{1,1}B_{1,2}\dots B_{1,C}
\vdots
B_{R,1}B_{R,2}\dots B_{R,C}
出力
爆発後の盤面を R 行で出力せよ。盤面の表し方は入力と同じ形式を用いること (R と C を出力する必要はない)。
入力例 1
4 4 .1.# ###. .#2. #.##
出力例 1
...# #... .... #...

- (1,2) にある爆弾の爆発によって、上図の青いマスと紫のマスが空きマスに変わります。
- (3,3) にある爆弾の爆発によって、上図の赤いマスと紫のマスが空きマスに変わります。
この例のように、爆弾が効果を及ぼす範囲に被りがあることもあります。
入力例 2
2 5 ..#.# ###.#
出力例 2
..#.# ###.#
爆弾が 1 つもないこともあります。
入力例 3
2 3 11# ###
出力例 3
... ..#
入力例 4
4 6 #.#3#. ###.#. ##.### #1..#.
出力例 4
...... #..... #....# ....#.
Score : 200 points
Problem Statement
We have a board with R rows running horizontally and C columns running vertically. Let (i,j) denote the square at the i-th row from the top and j-th column from the left.
You are given characters B_{i,j} representing the current states of (i,j).
. represents an empty square; # represents a square with a wall; 1, 2,\dots, 9 represent a square with a bomb of power 1,2,\dots,9, respectively.
At the next moment, all bombs will explode simultaneously. When a bomb explodes, every square whose Manhattan distance from the square with the bomb is not greater than the power of the bomb will turn into an empty square. Here, the Manhattan distance from (r_1,c_1) to (r_2,c_2) is |r_1-r_2|+|c_1-c_2|.
Print the board after the explosions.
Constraints
- 1\leq R,C \leq 20
- R and C are integers.
- Each B_{i,j} is one of
.,#,1,2, \dots,9.
Input
The input is given from Standard Input in the following format:
R C
B_{1,1}B_{1,2}\dots B_{1,C}
\vdots
B_{R,1}B_{R,2}\dots B_{R,C}
Output
Print R lines representing the board after the explosions. Use the format used in the input (do not print R or C).
Sample Input 1
4 4 .1.# ###. .#2. #.##
Sample Output 1
...# #... .... #...

- The explosion of the bomb at (1,2) will turn the blue squares and purple squares in the above figure into empty squares.
- The explosion of the bomb at (3,3) will turn the red squares and purple squares in the above figure into empty squares.
As seen in this sample, the explosion ranges of bombs may overlap.
Sample Input 2
2 5 ..#.# ###.#
Sample Output 2
..#.# ###.#
There may be no bombs.
Sample Input 3
2 3 11# ###
Sample Output 3
... ..#
Sample Input 4
4 6 #.#3#. ###.#. ##.### #1..#.
Sample Output 4
...... #..... #....# ....#.
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 200 点
問題文
1 から N までの番号がついた N 人の参加者が、1 から M までの番号がついた M 問からなるコンテストに参加します。
1 以上 N 以下の整数 i 、1 以上 M 以下の整数 j について、S_i の j 番目の文字が o のとき参加者 i は問題 j を解くことが可能で、S_i の j 番目の文字が x のとき参加者 i は問題 j を解くことが不可能です。
このコンテストは、二人の参加者でペアを組んで参加します。二人が協力することで M 問全てを解くことが可能であるようなペアの個数を答えてください。
より厳密には、1\leq x < y\leq N を満たす整数の組 (x,y) であって、 1 以上 M 以下の任意の整数 j について、参加者 x か参加者 y の少なくとも一方は問題 j を解くことが可能であるという条件を満たすものの個数を答えてください。
制約
- N は 2 以上 30 以下の整数
- M は 1 以上 30 以下の整数
- S_i は
o,xからなる長さ M の文字列
入力
入力は以下の形式で標準入力から与えられる。
N M S_1 S_2 \vdots S_N
出力
答えを出力せよ。
入力例 1
5 5 ooooo oooxx xxooo oxoxo xxxxx
出力例 1
5
参加者 1 と 2 のペア、参加者 1 と 3 のペア、参加者 1 と 4 のペア、参加者 1 と 5 のペア、参加者 2 と 3 のペアの 5 個のペアが条件を満たします。
例えば参加者 2 と 4 のペアは、問題 4 が解けないので条件を満たしません。
入力例 2
3 2 ox xo xx
出力例 2
1
入力例 3
2 4 xxxx oxox
出力例 3
0
Score : 200 points
Problem Statement
N participants, numbered 1 to N, will participate in a contest with M problems, numbered 1 to M.
For an integer i between 1 and N and an integer j between 1 and M, participant i can solve problem j if the j-th character of S_i is o, and cannot solve it if that character is x.
The participants must be in pairs. Print the number of ways to form a pair of participants who can collectively solve all the M problems.
More formally, print the number of pairs (x,y) of integers satisfying 1\leq x < y\leq N such that for any integer j between 1 and M, at least one of participant x and participant y can solve problem j.
Constraints
- N is an integer between 2 and 30, inclusive.
- M is an integer between 1 and 30, inclusive.
- S_i is a string of length M consisting of
oandx.
Input
The input is given from Standard Input in the following format:
N M S_1 S_2 \vdots S_N
Output
Print the answer.
Sample Input 1
5 5 ooooo oooxx xxooo oxoxo xxxxx
Sample Output 1
5
The following five pairs satisfy the condition: participants 1 and 2, participants 1 and 3, participants 1 and 4, participants 1 and 5, and participants 2 and 3.
On the other hand, the pair of participants 2 and 4, for instance, does not satisfy the condition because they cannot solve problem 4.
Sample Input 2
3 2 ox xo xx
Sample Output 2
1
Sample Input 3
2 4 xxxx oxox
Sample Output 3
0
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 300 点
問題文
H_1 行 W_1 列の行列 A と、H_2 行 W_2 列の行列 B が与えられます。
- 1 \leq i \leq H_1 かつ 1 \leq j \leq W_1 を満たす整数の組 (i, j) について、行列 A の i 行目 j 列目の要素は A_{i, j} です。
- 1 \leq i \leq H_2 かつ 1 \leq j \leq W_2 を満たす整数の組 (i, j) について、行列 B の i 行目 j 列目の要素は B_{i, j} です。
行列 A に対して、下記の 2 つの操作のうちどちらかを行うことを、好きなだけ( 0 回でも良い)繰り返すことができます。
- A の行を任意に 1 つ選んで削除する。
- A の列を任意に 1 つ選んで削除する。
行列 A を行列 B に一致させることができるかどうかを判定して下さい。
制約
- 1 \leq H_2 \leq H_1 \leq 10
- 1 \leq W_2 \leq W_1 \leq 10
- 1 \leq A_{i, j} \leq 10^9
- 1 \leq B_{i, j} \leq 10^9
- 入力中の値はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
H_1 W_1
A_{1, 1} A_{1, 2} \ldots A_{1, W_1}
A_{2, 1} A_{2, 2} \ldots A_{2, W_1}
\vdots
A_{H_1, 1} A_{H_1, 2} \ldots A_{H_1, W_1}
H_2 W_2
B_{1, 1} B_{1, 2} \ldots B_{1, W_2}
B_{2, 1} B_{2, 2} \ldots B_{2, W_2}
\vdots
B_{H_2, 1} B_{H_2, 2} \ldots B_{H_2, W_2}
出力
行列 A を行列 B に一致させることができる場合は Yes を、
一致させることができない場合は No を出力せよ。
ジャッジは英小文字と英大文字を厳密に区別することに注意せよ。
入力例 1
4 5 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2 3 6 8 9 16 18 19
出力例 1
Yes
初期状態の行列 A から 2 列目を削除すると、行列 A は
1 3 4 5 6 8 9 10 11 13 14 15 16 18 19 20
となります。そこからさらに 3 行目を削除すると、行列 A は
1 3 4 5 6 8 9 10 16 18 19 20
となります。そこからさらに 1 行目を削除すると、行列 A は
6 8 9 10 16 18 19 20
となります。そこからさらに 4 列目を削除すると、行列 A は
6 8 9 16 18 19
となります。これは行列 B と一致します。
操作の繰り返しによって行列 A を行列 B に一致させることができるので Yes を出力します。
入力例 2
3 3 1 1 1 1 1 1 1 1 1 1 1 2
出力例 2
No
どのように操作を行っても、 行列 A を行列 B に一致させることはできません。
よって、No を出力します。
Score : 300 points
Problem Statement
You are given a matrix A with H_1 rows and W_1 columns, and a matrix B with H_2 rows and W_2 columns.
- For all integer pairs (i, j) such that 1 \leq i \leq H_1 and 1 \leq j \leq W_1, the element at the i-th row and j-th column of matrix A is A_{i, j}.
- For all integer pairs (i, j) such that 1 \leq i \leq H_2 and 1 \leq j \leq W_2, the element at the i-th row and j-th column of matrix B is B_{i, j}.
You may perform the following operations on the matrix A any number of (possibly 0) times in any order:
- Choose an arbitrary row of A and remove it.
- Choose an arbitrary column of A and remove it.
Determine if it is possible to make the matrix A equal the matrix B.
Constraints
- 1 \leq H_2 \leq H_1 \leq 10
- 1 \leq W_2 \leq W_1 \leq 10
- 1 \leq A_{i, j} \leq 10^9
- 1 \leq B_{i, j} \leq 10^9
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
H_1 W_1
A_{1, 1} A_{1, 2} \ldots A_{1, W_1}
A_{2, 1} A_{2, 2} \ldots A_{2, W_1}
\vdots
A_{H_1, 1} A_{H_1, 2} \ldots A_{H_1, W_1}
H_2 W_2
B_{1, 1} B_{1, 2} \ldots B_{1, W_2}
B_{2, 1} B_{2, 2} \ldots B_{2, W_2}
\vdots
B_{H_2, 1} B_{H_2, 2} \ldots B_{H_2, W_2}
Output
Print Yes if it is possible to make the matrix A equal the matrix B;
print No otherwise.
Note that the judge is case-sensitive.
Sample Input 1
4 5 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2 3 6 8 9 16 18 19
Sample Output 1
Yes
Removing the 2-nd column from the initial A results in:
1 3 4 5 6 8 9 10 11 13 14 15 16 18 19 20
Then, removing the 3-rd row from A results in:
1 3 4 5 6 8 9 10 16 18 19 20
Then, removing the 1-st row from A results in:
6 8 9 10 16 18 19 20
Then, removing the 4-th column from A results in:
6 8 9 16 18 19
Now the matrix equals the matrix B.
Thus, we can make the matrix A equal the matrix B by repeating the operations, so Yes should be printed.
Sample Input 2
3 3 1 1 1 1 1 1 1 1 1 1 1 2
Sample Output 2
No
Regardless of how we perform the operations, we cannot make the matrix A equal the matrix B,
so No should be printed.