Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
下の画像で示す図において、a 番の点と b 番の点が線で直接結ばれているかを答えてください。
制約
- 1 \leq a \lt b \leq 10
- a, b は整数
入力
入力は以下の形式で標準入力から与えられる。
a b
出力
a 番の点と b 番の点が線で直接結ばれている場合は Yes
を出力し、結ばれていない場合は No
を出力せよ。
ジャッジは英大文字と英小文字を厳密に区別することに注意せよ。
入力例 1
4 5
出力例 1
Yes
問題文で示した図において、4 番の点と 5 番の点は線で直接結ばれています。
よって、Yes
を出力します。
入力例 2
3 5
出力例 2
No
問題文で示した図において、3 番の点と 5 番の点は線で直接結ばれていません。
よって、No
を出力します。
入力例 3
1 10
出力例 3
Yes
Score : 100 points
Problem Statement
In the figure shown in the image below, are the points numbered a and b directly connected by a line segment?
Constraints
- 1 \leq a \lt b \leq 10
- a and b are integers.
Input
Input is given from Standard Input in the following format:
a b
Output
If the points numbered a and b are directly connected by a line segment, print Yes
; otherwise, print No
.
The judge is case-sensitive: be sure to print uppercase and lowercase letters correctly.
Sample Input 1
4 5
Sample Output 1
Yes
In the figure shown in the Problem Statement, the points numbered 4 and 5 are directly connected by a line segment.
Thus, Yes
should be printed.
Sample Input 2
3 5
Sample Output 2
No
In the figure shown in the Problem Statement, the points numbered 3 and 5 are not directly connected by a line segment.
Thus, No
should be printed.
Sample Input 3
1 10
Sample Output 3
Yes
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
整数 N が与えられます。
N が -2^{31} 以上かつ 2^{31} 未満ならば Yes
を、そうでないならば No
を出力してください。
制約
- -2^{63} \leq N < 2^{63}
- N は整数である。
入力
入力は以下の形式で標準入力から与えられる。
N
出力
N が -2^{31} 以上かつ 2^{31} 未満ならば Yes
を、そうでないならば No
を出力せよ。
入力例 1
10
出力例 1
Yes
10 は -2^{31} 以上かつ 2^{31} 未満であるので、Yes
を出力します。
入力例 2
-9876543210
出力例 2
No
-9876543210 は -2^{31} 未満であるので、No
を出力します。
入力例 3
483597848400000
出力例 3
No
483597848400000 は 2^{31} 以上であるので、No
を出力します。
Score : 100 points
Problem Statement
You are given an integer N.
If N is between -2^{31} and 2^{31}-1 (inclusive), print Yes
; otherwise, print No
.
Constraints
- -2^{63} \leq N < 2^{63}
- N is an integer.
Input
Input is given from Standard Input in the following format:
N
Output
If N is between -2^{31} and 2^{31}-1 (inclusive), print Yes
; otherwise, print No
.
Sample Input 1
10
Sample Output 1
Yes
10 is between -2^{31} and 2^{31}-1, so Yes
should be printed.
Sample Input 2
-9876543210
Sample Output 2
No
-9876543210 is less than -2^{31}, so No
should be printed.
Sample Input 3
483597848400000
Sample Output 3
No
483597848400000 is greater than 2^{31}-1, so No
should be printed.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
N 人の人がいます。i \, (1 \leq i \leq N) 人目の人の姓は S_i、名は T_i です。
同姓同名であるような人の組が存在するか、すなわち 1 \leq i \lt j \leq N かつ S_i=S_j かつ T_i=T_j を満たすような整数対 (i,j) が存在するか判定してください。
制約
- 2 \leq N \leq 1000
- N は整数
- S_i,T_i は英小文字のみからなる長さ 1 以上 10 以下の文字列
入力
入力は以下の形式で標準入力から与えられる。
N S_1 T_1 S_2 T_2 \hspace{0.6cm}\vdots S_N T_N
出力
同姓同名であるような人の組が存在するなら Yes
を、存在しないなら No
を出力せよ。
入力例 1
3 tanaka taro sato hanako tanaka taro
出力例 1
Yes
1 人目の人と 3 人目の人が同姓同名です。
入力例 2
3 saito ichiro saito jiro saito saburo
出力例 2
No
同姓同名であるような人の組は存在しません。
入力例 3
4 sypdgidop bkseq bajsqz hh ozjekw mcybmtt qfeysvw dbo
出力例 3
No
Score : 200 points
Problem Statement
There are N people. The family name and given name of the i-th person (1 \leq i \leq N) are S_i and T_i, respectively.
Determine whether there is a pair of people with the same family and given names. In other words, determine whether there is a pair of integers (i,j) such that 1 \leq i \lt j \leq N, S_i=S_j, and T_i=T_j.
Constraints
- 2 \leq N \leq 1000
- N is an integer.
- Each of S_i and T_i is a string of length between 1 and 10 (inclusive) consisting of English lowercase letters.
Input
Input is given from Standard Input in the following format:
N S_1 T_1 S_2 T_2 \hspace{0.6cm}\vdots S_N T_N
Output
If there is a pair of people with the same family and given names, print Yes
; otherwise, print No
.
Sample Input 1
3 tanaka taro sato hanako tanaka taro
Sample Output 1
Yes
The first and third persons have the same family and given names.
Sample Input 2
3 saito ichiro saito jiro saito saburo
Sample Output 2
No
No two persons have the same family and given names.
Sample Input 3
4 sypdgidop bkseq bajsqz hh ozjekw mcybmtt qfeysvw dbo
Sample Output 3
No
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
無限に長いピアノの鍵盤があります。 この鍵盤内の連続する区間であって、白鍵 W 個と黒鍵 B 個からなるものは存在しますか?
文字列 wbwbwwbwbwbw
を無限に繰り返してできる文字列を S とおきます。
S の部分文字列であって、W 個の w
と B 個の b
からなるものは存在しますか?
S の部分文字列とは
S の部分文字列とは、ある 2 つの正整数 l,r\ (l\leq r) に対して、S の l 文字目、l+1 文字目、\dots、r 文字目をこの順に繋げてできる文字列のことをいいます。制約
- W,B は整数
- 0\leq W,B \leq 100
- W+B \geq 1
入力
入力は以下の形式で標準入力から与えられる。
W B
出力
S の部分文字列であって、W 個の w
と B 個の b
からなるものが存在するならば Yes
を、存在しないならば No
を出力せよ。
入力例 1
3 2
出力例 1
Yes
S の最初の 15 文字は wbwbwwbwbwbwwbw
であり、S の 11 文字目から 15 文字目までを取り出してできる文字列 bwwbw
は 3 個の w
と 2 個の b
からなる部分文字列の一例です。
入力例 2
3 0
出力例 2
No
3 個の w
と 0 個の b
からなる文字列は www
のみですが、これは S の部分文字列ではありません。
入力例 3
92 66
出力例 3
Yes
Score: 200 points
Problem Statement
There is an infinitely long piano keyboard. Is there a continuous segment within this keyboard that consists of W white keys and B black keys?
Let S be the string formed by infinitely repeating the string wbwbwwbwbwbw
.
Is there a substring of S that consists of W occurrences of w
and B occurrences of b
?
What is a substring of S?
A substring of S is a string that can be formed by concatenating the l-th, (l+1)-th, \dots, r-th characters of S in this order for some two positive integers l and r (l\leq r).Constraints
- W and B are integers.
- 0\leq W,B \leq 100
- W+B \geq 1
Input
The input is given from Standard Input in the following format:
W B
Output
If there is a substring of S that consists of W occurrences of w
and B occurrences of b
, print Yes
; otherwise, print No
.
Sample Input 1
3 2
Sample Output 1
Yes
The first 15 characters of S are wbwbwwbwbwbwwbw
. You can take the 11-th through 15-th characters to form the string bwwbw
, which is a substring consisting of three occurrences of w
and two occurrences of b
.
Sample Input 2
3 0
Sample Output 2
No
The only string consisting of three occurrences of w
and zero occurrences of b
is www
, which is not a substring of S.
Sample Input 3
92 66
Sample Output 3
Yes
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 300 点
問題文
長さ N の非負整数列 A が与えられます。
A から K 要素を選んで順序を保ったまま抜き出した列を B としたとき、 MEX(B) としてありえる最大値を求めてください。
但し、数列 X に対して MEX(X) は以下の条件を満たす唯一の非負整数 m として定義されます。
- 0 \le i < m を満たす全ての整数 i が X に含まれる。
- m が X に含まれない。
制約
- 入力は全て整数
- 1 \le K \le N \le 3 \times 10^5
- 0 \le A_i \le 10^9
入力
入力は以下の形式で標準入力から与えられる。
N K A_1 A_2 \dots A_N
出力
答えを出力せよ。
入力例 1
7 3 2 0 2 3 2 1 9
出力例 1
3
この入力では A=(2,0,2,3,2,1,9) であり、ここから K=3 要素を選んで抜き出して数列 B を得ます。例えば、
- 1,2,3 要素目を抜き出した時、 MEX(B)=MEX(2,0,2)=1
- 3,4,6 要素目を抜き出した時、 MEX(B)=MEX(2,3,1)=0
- 2,6,7 要素目を抜き出した時、 MEX(B)=MEX(0,1,9)=2
- 2,3,6 要素目を抜き出した時、 MEX(B)=MEX(0,2,1)=3
のようになります。
達成可能な MEX の最大値は 3 です。
Score : 300 points
Problem Statement
You are given a length-N sequence of non-negative integers.
When B is a sequence obtained by choosing K elements from A and concatenating them without changing the order, find the maximum possible value of MEX(B).
Here, for a sequence X, we define MEX(X) as the unique non-negative integer m that satisfies the following conditions:
- Every integer i such that 0 \le i < m is contained in X.
- m is not contained in X.
Constraints
- All values in the input are integers.
- 1 \le K \le N \le 3 \times 10^5
- 0 \le A_i \le 10^9
Input
The input is given from Standard Input in the following format:
N K A_1 A_2 \dots A_N
Output
Print the answer.
Sample Input 1
7 3 2 0 2 3 2 1 9
Sample Output 1
3
In this input, A=(2,0,2,3,2,1,9), and you obtain the sequence B by picking K=3 elements. For example,
- If the 1-st, 2-nd, and 3-rd elements are chosen, MEX(B)=MEX(2,0,2)=1.
- If the 3-rd, 4-th, and 6-th elements are chosen, MEX(B)=MEX(2,3,1)=0.
- If the 2-nd, 6-th, and 7-th elements are chosen, MEX(B)=MEX(0,1,9)=2.
- If the 2-nd, 3-rd, and 6-th elements are chosen, MEX(B)=MEX(0,2,1)=3.
The maximum possible MEX is 3.