Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
英小文字および . からなる文字列 S が与えられます。
S から . を全て削除した文字列を求めてください。
制約
- S は英小文字および
.からなる長さ 1 以上 100 以下の文字列
入力
入力は以下の形式で標準入力から与えられる。
S
出力
S から . を全て削除した文字列を出力せよ。
入力例 1
.v.
出力例 1
v
.v. から . を全て削除すると v になります。したがって、 v を出力してください。
入力例 2
chokudai
出力例 2
chokudai
S に . が含まれない場合もあります。
入力例 3
...
出力例 3
S の文字が全て . である場合もあります。
Score : 100 points
Problem Statement
You are given a string S consisting of lowercase English letters and ..
Find the string obtained by removing all . from S.
Constraints
- S is a string of length between 1 and 100, inclusive, consisting of lowercase English letters and
..
Input
The input is given from Standard Input in the following format:
S
Output
Print the string obtained by removing all . from S.
Sample Input 1
.v.
Sample Output 1
v
Removing all . from .v. yields v, so print v.
Sample Input 2
chokudai
Sample Output 2
chokudai
There are cases where S does not contain ..
Sample Input 3
...
Sample Output 3
There are also cases where all characters in S are ..
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
正整数 A,B が与えられます。
A+B の二乗を出力してください。
制約
- 1\leq A,B \leq 2025
- 入力は全て整数
入力
入力は以下の形式で標準入力から与えられる。
A B
出力
答えを出力せよ。
入力例 1
20 25
出力例 1
2025
(20+25)^2=2025 です。
入力例 2
30 25
出力例 2
3025
入力例 3
45 11
出力例 3
3136
入力例 4
2025 1111
出力例 4
9834496
Score : 100 points
Problem Statement
You are given two positive integers A and B.
Output the square of A + B.
Constraints
- 1 \leq A,B \leq 2025
- All input values are integers.
Input
The input is given from Standard Input in the following format:
A B
Output
Print the answer.
Sample Input 1
20 25
Sample Output 1
2025
(20+25)^2=2025.
Sample Input 2
30 25
Sample Output 2
3025
Sample Input 3
45 11
Sample Output 3
3136
Sample Input 4
2025 1111
Sample Output 4
9834496
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
1,2,\ldots,N の番号がついた N 人の人がいます。
M 回の舞踏会が行われました。 i (1\leq i \leq M) 回目の舞踏会には k_i 人が参加し、参加した人は人 x_{i,1},x_{i,2},\ldots,x_{i,k_i} でした。
どの二人も少なくとも 1 回同じ舞踏会に参加したか判定してください。
制約
- 2\leq N \leq 100
- 1\leq M \leq 100
- 2\leq k_i \leq N
- 1\leq x_{i,1}<x_{i,2}<\ldots < x_{i,k_i}\leq N
- 入力は全て整数
入力
入力は以下の形式で標準入力から与えられる。
N M
k_1 x_{1,1} x_{1,2} \ldots x_{1,k_1}
\vdots
k_M x_{M,1} x_{M,2} \ldots x_{M,k_M}
出力
どの二人も少なくとも 1 回同じ舞踏会に参加した場合 Yes を、そうでない場合 No を出力せよ。
入力例 1
3 3 2 1 2 2 2 3 2 1 3
出力例 1
Yes
人 1 と人 2 は共に 1 回目の舞踏会に参加しています。
人 2 と人 3 は共に 2 回目の舞踏会に参加しています。
人 1 と人 3 は共に 3 回目の舞踏会に参加しています。
以上よりどの二人も少なくとも 1 回同じ舞踏会に参加したので、答えは Yes です。
入力例 2
4 2 3 1 2 4 3 2 3 4
出力例 2
No
人 1 と人 3 は 1 回も同じ舞踏会に参加していないので、答えは No です。
Score : 200 points
Problem Statement
There are N people numbered 1,2,\ldots,N.
M parties were held. k_i people attended the i-th (1\leq i \leq M) party, and they were People x_{i,1},x_{i,2},\ldots,x_{i,k_i}.
Determine if every two people attended the same party at least once.
Constraints
- 2\leq N \leq 100
- 1\leq M \leq 100
- 2\leq k_i \leq N
- 1\leq x_{i,1}<x_{i,2}<\ldots < x_{i,k_i}\leq N
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
N M
k_1 x_{1,1} x_{1,2} \ldots x_{1,k_1}
\vdots
k_M x_{M,1} x_{M,2} \ldots x_{M,k_M}
Output
Print Yes if every two people attended the same party at least once; print No otherwise.
Sample Input 1
3 3 2 1 2 2 2 3 2 1 3
Sample Output 1
Yes
Both Person 1 and Person 2 attended the 1-st party.
Both Person 2 and Person 3 attended the 2-nd party.
Both Person 1 and Person 3 attended the 3-rd party.
Therefore, every two people attended the same party at least once, so the answer is Yes.
Sample Input 2
4 2 3 1 2 4 3 2 3 4
Sample Output 2
No
Person 1 and Person 3 did not attend the same party, so the answer is No.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
長さ N の数列 A=(A_1,A_2,\dots,A_N) と、長さ M の数列 B=(B_1,B_2,\dots,B_M) が与えられます。ここで、A,B のすべての要素は互いに相異なります。A,B のすべての要素を昇順に並べた長さ N+M の数列 C=(C_1,C_2,\dots,C_{N+M}) において、A に現れる要素が2つ連続するかどうか判定してください。
制約
- 1\leq N,M \leq 100
- 1\leq A_i,B_j \leq 200
- A_1, A_2, \dots, A_N, B_1, B_2, \dots, B_M は相異なる
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N M A_1 A_2 \dots A_N B_1 B_2 \dots B_M
出力
A に現れる要素が C において2つ連続するならば Yes を、そうでないなら No を出力せよ。
入力例 1
3 2 3 2 5 4 1
出力例 1
Yes
C=(1,2,3,4,5) です。A に現れる 2,3 が C で連続しているため、Yes を出力します。
入力例 2
3 2 3 1 5 4 2
出力例 2
No
C=(1,2,3,4,5) です。A に現れる要素が C で連続している箇所はないため、No を出力します。
入力例 3
1 1 1 2
出力例 3
No
Score : 200 points
Problem Statement
You are given a sequence A=(A_1,A_2,\dots,A_N) of length N and a sequence B=(B_1,B_2,\dots,B_M) of length M. Here, all elements of A and B are pairwise distinct. Determine whether the sequence C=(C_1,C_2,\dots,C_{N+M}) formed by sorting all elements of A and B in ascending order contains two consecutive elements appearing in A.
Constraints
- 1 \leq N, M \leq 100
- 1 \leq A_i, B_j \leq 200
- A_1, A_2, \dots, A_N, B_1, B_2, \dots, B_M are distinct.
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N M A_1 A_2 \dots A_N B_1 B_2 \dots B_M
Output
If C contains two consecutive elements appearing in A, print Yes; otherwise, print No.
Sample Input 1
3 2 3 2 5 4 1
Sample Output 1
Yes
C=(1,2,3,4,5). Since 2 and 3 from A occur consecutively in C, print Yes.
Sample Input 2
3 2 3 1 5 4 2
Sample Output 2
No
C=(1,2,3,4,5). Since no two elements from A occur consecutively in C, print No.
Sample Input 3
1 1 1 2
Sample Output 3
No
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 300 点
問題文
高橋君が運営する SNS「Twidai」にはユーザー 1 からユーザー N までの N 人のユーザーがいます。 Twidai では、ユーザーは別のユーザーをフォローすることや、フォローを解除することができます。
Twidai がサービスを開始してから、Q 回の操作が行われました。 i 回目 (1\leq i\leq Q) の操作は 3 つの整数 T _ i, A _ i, B _ i で表され、それぞれ次のような操作を表します。
- T _ i=1 のとき:ユーザー A _ i がユーザー B _ i をフォローしたことを表す。この操作の時点でユーザー A _ i がユーザー B _ i をフォローしている場合、ユーザーのフォロー状況に変化はない。
- T _ i=2 のとき:ユーザー A _ i がユーザー B _ i のフォローを解除したことを表す。この操作の時点でユーザー A _ i がユーザー B _ i をフォローしていない場合、ユーザーのフォロー状況に変化はない。
- T _ i=3 のとき:ユーザー A _ i とユーザー B _ i が互いにフォローしているかをチェックすることを表す。この操作の時点でユーザー A _ i がユーザー B _ i をフォローしており、かつユーザー B _ i がユーザー A _ i をフォローしているとき、このチェックに対して
Yesと答え、そうでないときこのチェックに対してNoと答える必要がある。
サービス開始時には、どのユーザーも他のユーザーをフォローしていません。
すべての T _ i=3 であるような操作に対して、i が小さいほうから順番に正しい答えを出力してください。
制約
- 2 \leq N \leq 10 ^ 9
- 1 \leq Q \leq 2\times10 ^ 5
- T _ i=1,2,3\ (1\leq i\leq Q)
- 1 \leq A _ i \leq N\ (1\leq i\leq Q)
- 1 \leq B _ i \leq N\ (1\leq i\leq Q)
- A _ i\neq B _ i\ (1\leq i\leq Q)
- T _ i=3 となる i\ (1\leq i\leq Q) が存在する
- 入力される値はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N Q T _ 1 A _ 1 B _ 1 T _ 2 A _ 2 B _ 2 \vdots T _ Q A _ Q B _ Q
出力
T _ i=3 であるような i\ (1\leq i\leq Q) の個数を X として、X 行出力せよ。 j\ (1\leq j\leq X) 行目には j 番目の T _ i=3 であるような操作に対する答えを出力せよ。
入力例 1
3 9 1 1 2 3 1 2 1 2 1 3 1 2 1 2 3 1 3 2 3 1 3 2 1 2 3 1 2
出力例 1
No Yes No No
Twidai には 3 人のユーザーがいます。 9 回の操作はそれぞれ次のようになっています。
- ユーザー 1 がユーザー 2 をフォローします。そのほかにフォローしている/されているユーザーはいません。
- ユーザー 1 とユーザー 2 が互いにフォローしているかチェックします。ユーザー 1 はユーザー 2 をフォローしていますが、ユーザー 2 はユーザー 1 をフォローしていません。この操作への正しい答えは
Noです。 - ユーザー 2 がユーザー 1 をフォローします。
- ユーザー 1 とユーザー 2 が互いにフォローしているかチェックします。ユーザー 1 はユーザー 2 をフォローしており、ユーザー 2 はユーザー 1 をフォローしています。この操作への正しい答えは
Yesです。 - ユーザー 2 がユーザー 3 をフォローします。
- ユーザー 3 がユーザー 2 をフォローします。
- ユーザー 1 とユーザー 3 が互いにフォローしているかチェックします。ユーザー 1 はユーザー 3 をフォローしておらず、ユーザー 3 もユーザー 1 をフォローしていません。この操作への正しい答えは
Noです。 - ユーザー 1 がユーザー 2 のフォローを解除します。
- ユーザー 1 とユーザー 2 が互いにフォローしているかチェックします。ユーザー 2 はユーザー 1 をフォローしていますが、ユーザー 1 はユーザー 2 をフォローしていません。この操作への正しい答えは
Noです。
入力例 2
2 8 1 1 2 1 2 1 3 1 2 1 1 2 1 1 2 1 1 2 2 1 2 3 1 2
出力例 2
Yes No
同じユーザーに対して何度もフォロー操作をする場合があります。
入力例 3
10 30 3 1 6 3 5 4 1 6 1 3 1 7 3 8 4 1 1 6 2 4 3 1 6 5 1 5 6 1 1 8 1 8 1 2 3 10 1 7 6 3 5 6 1 6 7 3 6 7 1 9 5 3 8 6 3 3 8 2 6 9 1 7 1 3 10 8 2 9 2 1 10 9 2 6 10 2 6 8 3 1 6 3 1 8 2 8 5 1 9 10
出力例 3
No No No No Yes Yes No No No Yes Yes
Score : 300 points
Problem Statement
Takahashi runs an SNS "Twidai," which has N users from user 1 through user N. In Twidai, users can follow or unfollow other users.
Q operations have been performed since Twidai was launched. The i-th (1\leq i\leq Q) operation is represented by three integers T_i, A_i, and B_i, whose meanings are as follows:
- If T_i = 1: it means that user A_i follows user B_i. If user A_i is already following user B_i at the time of this operation, it does not make any change.
- If T_i = 2: it means that user A_i unfollows user B_i. If user A_i is not following user B_i at the time of this operation, it does not make any change.
- If T_i = 3: it means that you are asked to determine if users A_i and B_i are following each other. You need to print
Yesif user A_i is following user B_i and user B_i is following user A_i, andNootherwise.
When the service was launched, no users were following any users.
Print the correct answers for all operations such that T_i = 3 in ascending order of i.
Constraints
- 2 \leq N \leq 10 ^ 9
- 1 \leq Q \leq 2\times10 ^ 5
- T _ i=1,2,3\ (1\leq i\leq Q)
- 1 \leq A _ i \leq N\ (1\leq i\leq Q)
- 1 \leq B _ i \leq N\ (1\leq i\leq Q)
- A _ i\neq B _ i\ (1\leq i\leq Q)
- There exists i\ (1\leq i\leq Q) such that T _ i=3.
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
N Q T _ 1 A _ 1 B _ 1 T _ 2 A _ 2 B _ 2 \vdots T _ Q A _ Q B _ Q
Output
Print X lines, where X is the number of i's (1\leq i\leq Q) such that T _ i=3. The j-th (1\leq j\leq X) line should contain the answer to the j-th operation such that T _ i=3.
Sample Input 1
3 9 1 1 2 3 1 2 1 2 1 3 1 2 1 2 3 1 3 2 3 1 3 2 1 2 3 1 2
Sample Output 1
No Yes No No
Twidai has three users. The nine operations are as follows.
- User 1 follows user 2. No other users are following or followed by any users.
- Determine if users 1 and 2 are following each other. User 1 is following user 2, but user 2 is not following user 1, so
Nois the correct answer to this operation. - User 2 follows user 1.
- Determine if users 1 and 2 are following each other. User 1 is following user 2, and user 2 is following user 1, so
Yesis the correct answer to this operation. - User 2 follows user 3.
- User 3 follows user 2.
- Determine if users 1 and 3 are following each other. User 1 is not following user 3, and user 3 is not following user 1, so
Nois the correct answer to this operation. - User 1 unfollows user 2.
- Determine if users 1 and 2 are following each other. User 2 is following user 1, but user 1 is not following user 2, so
Nois the correct answer to this operation.
Sample Input 2
2 8 1 1 2 1 2 1 3 1 2 1 1 2 1 1 2 1 1 2 2 1 2 3 1 2
Sample Output 2
Yes No
A user may follow the same user multiple times.
Sample Input 3
10 30 3 1 6 3 5 4 1 6 1 3 1 7 3 8 4 1 1 6 2 4 3 1 6 5 1 5 6 1 1 8 1 8 1 2 3 10 1 7 6 3 5 6 1 6 7 3 6 7 1 9 5 3 8 6 3 3 8 2 6 9 1 7 1 3 10 8 2 9 2 1 10 9 2 6 10 2 6 8 3 1 6 3 1 8 2 8 5 1 9 10
Sample Output 3
No No No No Yes Yes No No No Yes Yes