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
配点 : 100 点
問題文
N 人が一列に並んでいます。列の状態は長さ N の文字列 S で与えられ、前から i 番目の人は S の i 文字目が M のとき男性、F のとき女性です。
男女が交互に並んでいるかどうか判定してください。
男性同士が隣り合う箇所も女性同士が隣り合う箇所も存在しないとき、かつ、そのときに限り、男女が交互に並んでいるといいます。
制約
- 1 \leq N \leq 100
- N は整数である
- S は
MおよびFのみからなる長さ N の文字列である
入力
入力は以下の形式で標準入力から与えられる。
N S
出力
男女が交互に並んでいるとき Yes、そうでないとき No と出力せよ。
入力例 1
6 MFMFMF
出力例 1
Yes
男性同士が隣り合う箇所も女性同士が隣り合う箇所も存在せず、男女が交互に並んでいます。
入力例 2
9 FMFMMFMFM
出力例 2
No
入力例 3
1 F
出力例 3
Yes
Score : 100 points
Problem Statement
There is a row of N people. They are described by a string S of length N. The i-th person from the front is male if the i-th character of S is M, and female if it is F.
Determine whether the men and women are alternating.
It is said that the men and women are alternating if and only if there is no position where two men or two women are adjacent.
Constraints
- 1 \leq N \leq 100
- N is an integer.
- S is a string of length N consisting of
MandF.
Input
The input is given from Standard Input in the following format:
N S
Output
Print Yes if the men and women are alternating, and No otherwise.
Sample Input 1
6 MFMFMF
Sample Output 1
Yes
There is no position where two men or two women are adjacent, so the men and women are alternating.
Sample Input 2
9 FMFMMFMFM
Sample Output 2
No
Sample Input 3
1 F
Sample Output 3
Yes
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
3 桁の正整数であって、百の位の数と十の位の数の積が一の位の数と等しいものを 326-like number と呼びます。
例えば 326,400,144 は 326-like number であり、623,777,429 は 326-like number ではありません。
整数 N が与えられるので、N 以上の最小の 326-like number を求めてください。なお、制約の条件下で答えは必ず存在します。
制約
- 100 \leq N \leq 919
- N は整数である
入力
入力は以下の形式で標準入力から与えられる。
N
出力
答えを出力せよ。
入力例 1
320
出力例 1
326
320,321,322,323,324,325 は 326-like number ではなく、326 は 326-like number です。
入力例 2
144
出力例 2
144
144 は 326-like number です。
入力例 3
516
出力例 3
600
Score : 200 points
Problem Statement
A 326-like number is a three-digit positive integer where the product of the hundreds and tens digits equals the ones digit.
For example, 326,400,144 are 326-like numbers, while 623,777,429 are not.
Given an integer N, find the smallest 326-like number greater than or equal to N. It always exists under the constraints.
Constraints
- 100 \leq N \leq 919
- N is an integer.
Input
The input is given from Standard Input in the following format:
N
Output
Print the answer.
Sample Input 1
320
Sample Output 1
326
320,321,322,323,324,325 are not 326-like numbers, while 326 is a 326-like number.
Sample Input 2
144
Sample Output 2
144
144 is a 326-like number.
Sample Input 3
516
Sample Output 3
600
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
英小文字からなる文字列 S が良い文字列であるとは、すべての 1 以上の整数 i について次の性質が成り立つことであるとします。
- S にちょうど i 回現れる文字はちょうど 0 種類またはちょうど 2 種類ある
文字列 S が与えられるので、 S が良い文字列か判定してください。
制約
- S は英小文字からなる長さ 1 以上 100 以下の文字列
入力
入力は以下の形式で標準入力から与えられる。
S
出力
S が良い文字列ならば Yes を、そうでないならば No を出力せよ。
入力例 1
commencement
出力例 1
Yes
文字列 commencement にちょうど i 回現れる文字の種類数は以下のとおりです。
- i=1:
o,tの 2 種類 - i=2:
c,nの 2 種類 - i=3:
e,mの 2 種類 - i\geq 4: 0 種類
よって、commencement は良い文字列の条件を満たします。
入力例 2
banana
出力例 2
No
文字列 banana にちょうど 1 回現れる文字は b の 1 種類だけであり、良い文字列の条件を満たしません。
入力例 3
ab
出力例 3
Yes
Score: 200 points
Problem Statement
A string S consisting of lowercase English letters is a good string if and only if it satisfies the following property for all integers i not less than 1:
- There are exactly zero or exactly two different letters that appear exactly i times in S.
Given a string S, determine if it is a good string.
Constraints
- S is a string of lowercase English letters with a length between 1 and 100, inclusive.
Input
The input is given from Standard Input in the following format:
S
Output
Print Yes if S is a good string, and No otherwise.
Sample Input 1
commencement
Sample Output 1
Yes
For the string commencement, the number of different letters that appear exactly i times is as follows:
- i=1: two letters (
oandt) - i=2: two letters (
candn) - i=3: two letters (
eandm) - i\geq 4: zero letters
Therefore, commencement satisfies the condition of a good string.
Sample Input 2
banana
Sample Output 2
No
For the string banana, there is only one letter that appears exactly one time, which is b, so it does not satisfy the condition of a good string.
Sample Input 3
ab
Sample Output 3
Yes
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 300 点
問題文
N 頂点 M 辺の単純無向グラフが与えられます。頂点には 1,2,\dots,N の番号が、辺には 1,2,\dots,M の番号がつけられており、辺 i は頂点 A_i と頂点 B_i を結んでいます。
このグラフがサイクルグラフであるか判定してください。
単純無向グラフとは
単純無向グラフとは、自己ループや多重辺を含まず、辺に向きの無いグラフのことをいいます。
サイクルグラフとは
頂点に 1, 2, \dots, N の番号が付けられた N 頂点のグラフがサイクルグラフであるとは、(1, 2, \dots, N) を並べ変えて得られる数列 (v_1, v_2, \dots, v_N) であって、以下の条件を満たすものが存在することをいいます。
制約
- 3\leq N \leq 2\times 10^5
- 0 \leq M \leq 2\times 10^5
- 1 \leq A_i, B_i \leq N
- 与えられるグラフは単純
- 入力は全て整数
入力
入力は以下の形式で標準入力から与えられる。
N M A_1 B_1 \vdots A_M B_M
出力
与えられたグラフがサイクルグラフであるなら Yes、そうでないなら No と出力せよ。
入力例 1
4 4 2 4 3 1 4 1 2 3
出力例 1
Yes
与えられたグラフは以下の通りであり、これはサイクルグラフです。

入力例 2
4 6 1 2 1 3 1 4 2 3 2 4 3 4
出力例 2
No
与えられたグラフは以下の通りであり、これはサイクルグラフではありません。

Score : 300 points
Problem Statement
You are given a simple undirected graph with N vertices and M edges. The vertices are numbered 1,2,\dots,N and the edges are numbered 1,2,\dots,M. Edge i connects vertices A_i and B_i.
Determine whether this graph is a cycle graph.
Definition of simple undirected graph
A simple undirected graph is a graph with undirected edges without self-loops or multi-edges.
Definition of cycle graph
An N-vertex graph with vertices labeled 1,2,\dots,N is a cycle graph when there exists a permutation (v_1,v_2,\dots,v_N) of (1,2,\dots,N) such that:
Constraints
- 3 \le N \le 2\times 10^5
- 0 \le M \le 2\times 10^5
- 1 \le A_i, B_i \le N
- The given graph is simple.
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N M A_1 B_1 \vdots A_M B_M
Output
Output Yes if the given graph is a cycle graph; otherwise, print No.
Sample Input 1
4 4 2 4 3 1 4 1 2 3
Sample Output 1
Yes
The given graph is as follows, and this is a cycle graph.

Sample Input 2
4 6 1 2 1 3 1 4 2 3 2 4 3 4
Sample Output 2
No
The given graph is as follows, and this is not a cycle graph.
