実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 100 点
問題文
AtCoder マンションには 1 号室から N 号室までの N 個の部屋があります。
各 i 号室には S_i さんが 1 人で住んでいます。
あなたは X 号室の Y さん宛に荷物を届けようとしています。宛先が正しいかどうかを判定してください。
制約
- 1 \leq N \leq 100
- 1 \leq X \leq N
- N,X は整数
- S_i および Y は英小文字のみからなる長さ 1 以上 10 以下の文字列
入力
入力は以下の形式で標準入力から与えられる。
N S_1 S_2 \vdots S_N X Y
出力
X 号室に住んでいる人の名前が Y であるとき Yes、そうでないとき No と出力せよ。
入力例 1
3 sato suzuki takahashi 3 takahashi
出力例 1
Yes
3 号室に住んでいるのは takahashi さんであり、荷物の宛名と一致しています。
入力例 2
3 sato suzuki takahashi 1 aoki
出力例 2
No
1 号室に住んでいるのは sato さんであり、荷物の宛名である aoki と一致しません。
入力例 3
2 smith smith 1 smith
出力例 3
Yes
AtCoder マンションには異なる部屋に同じ名前の人が住んでいることがあります。
入力例 4
2 wang li 2 wang
出力例 4
No
Score : 100 points
Problem Statement
Mansion AtCoder has N rooms numbered from room 1 to room N.
Each room i is inhabited by one person named S_i.
You are to deliver a package addressed to Mr./Ms. Y in room X. Determine whether the destination is correct.
Constraints
- 1 \leq N \leq 100
- 1 \leq X \leq N
- N and X are integers.
- S_i and Y are strings consisting of lowercase English letters with length between 1 and 10, inclusive.
Input
The input is given from Standard Input in the following format:
N S_1 S_2 \vdots S_N X Y
Output
Print Yes if the name of the person living in room X is Y, and No otherwise.
Sample Input 1
3 sato suzuki takahashi 3 takahashi
Sample Output 1
Yes
The person living in room 3 is takahashi, which matches the name on the package.
Sample Input 2
3 sato suzuki takahashi 1 aoki
Sample Output 2
No
The person living in room 1 is sato, which does not match the name on the package, aoki.
Sample Input 3
2 smith smith 1 smith
Sample Output 3
Yes
Mansion AtCoder may have people with the same name living in different rooms.
Sample Input 4
2 wang li 2 wang
Sample Output 4
No
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 100 点
問題文
文字列 S が与えられます。ここで、S の 1 文字目は英大文字、2 文字目以降は英小文字です。
S の 1 文字目と UPC をこの順に結合した文字列を出力してください。
制約
- S は長さ 1 以上 100 以下の文字列
- S の 1 文字目は英大文字
- S の 2 文字目以降は英小文字
入力
入力は以下の形式で標準入力から与えられる。
S
出力
S の 1 文字目と UPC をこの順に結合した文字列を出力せよ。
入力例 1
Kyoto
出力例 1
KUPC
Kyoto の 1 文字目は K であるため、K と UPC を結合した KUPC を出力します。
入力例 2
Tohoku
出力例 2
TUPC
Score : 100 points
Problem Statement
You are given a string S. Here, the first character of S is an uppercase English letter, and the second and subsequent characters are lowercase English letters.
Print the string formed by concatenating the first character of S and UPC in this order.
Constraints
- S is a string of length between 1 and 100, inclusive.
- The first character of S is an uppercase English letter.
- The second and subsequent characters of S are lowercase English letters.
Input
The input is given from Standard Input in the following format:
S
Output
Print the string formed by concatenating the first character of S and UPC in this order.
Sample Input 1
Kyoto
Sample Output 1
KUPC
The first character of Kyoto is K, so concatenate K and UPC, and print KUPC.
Sample Input 2
Tohoku
Sample Output 2
TUPC
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 250 点
問題文
あなたは3Dゲームの当たり判定を実装しようとしています。
3 次元空間内の直方体であって、2 点 (a,b,c),(d,e,f) を結ぶ線分を対角線とし、全ての面が xy 平面、yz 平面、zx 平面のいずれかに平行なものを C(a,b,c,d,e,f) と表します。
(この定義により C(a,b,c,d,e,f) は一意に定まります)
2 つの直方体 C(a,b,c,d,e,f) と C(g,h,i,j,k,l) が与えられるので、これらの共通部分の体積が正かどうか判定してください。
制約
- 0 \leq a < d \leq 1000
- 0 \leq b < e \leq 1000
- 0 \leq c < f \leq 1000
- 0 \leq g < j \leq 1000
- 0 \leq h < k \leq 1000
- 0 \leq i < l \leq 1000
- 入力は全て整数
入力
入力は以下の形式で標準入力から与えられる。
a b c d e f g h i j k l
出力
2 つの直方体の共通部分の体積が正なら Yes、そうでなければ No を出力せよ。
入力例 1
0 0 0 4 5 6 2 3 4 5 6 7
出力例 1
Yes
2 つの直方体の位置関係は下図のようになっており、共通部分の体積は 8 です。

入力例 2
0 0 0 2 2 2 0 0 2 2 2 4
出力例 2
No
2 つの直方体は面で接していますが、共通部分の体積は 0 です。
入力例 3
0 0 0 1000 1000 1000 10 10 10 100 100 100
出力例 3
Yes
Score : 250 points
Problem Statement
You are trying to implement collision detection in a 3D game.
In a 3-dimensional space, let C(a,b,c,d,e,f) denote the cuboid with a diagonal connecting (a,b,c) and (d,e,f), and with all faces parallel to the xy-plane, yz-plane, or zx-plane.
(This definition uniquely determines C(a,b,c,d,e,f).)
Given two cuboids C(a,b,c,d,e,f) and C(g,h,i,j,k,l), determine whether their intersection has a positive volume.
Constraints
- 0 \leq a < d \leq 1000
- 0 \leq b < e \leq 1000
- 0 \leq c < f \leq 1000
- 0 \leq g < j \leq 1000
- 0 \leq h < k \leq 1000
- 0 \leq i < l \leq 1000
- All input values are integers.
Input
The input is given from Standard Input in the following format:
a b c d e f g h i j k l
Output
Print Yes if the intersection of the two cuboids has a positive volume, and No otherwise.
Sample Input 1
0 0 0 4 5 6 2 3 4 5 6 7
Sample Output 1
Yes
The positional relationship of the two cuboids is shown in the figure below, and their intersection has a volume of 8.

Sample Input 2
0 0 0 2 2 2 0 0 2 2 2 4
Sample Output 2
No
The two cuboids touch at a face, where the volume of the intersection is 0.
Sample Input 3
0 0 0 1000 1000 1000 10 10 10 100 100 100
Sample Output 3
Yes
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 200 点
問題文
1 から N の番号がついた N 頭の馬が競争をしました。
全ての馬は同時にスタートし、 i 番の馬はスタートからゴールまで T_i 秒かかりました。
1,2,3 着の馬の番号を求めてください。なお、 T_i は相異なることが保証されます。
制約
- 3\leq N \leq 32
- 1\leq T_i \leq 200
- T_i は相異なる
- 入力は全て整数
入力
入力は以下の形式で標準入力から与えられる。
N T_1 \dots T_N
出力
1,2,3 着の馬の番号をそれぞれ空白区切りでこの順に出力せよ。
入力例 1
4 100 110 105 95
出力例 1
4 1 3
4,1,3,2 番の順にゴールしました。1,2,3 着の番号である 4,1,3 をこの順に空白区切りで出力してください。
入力例 2
8 72 74 69 70 73 75 71 77
出力例 2
3 4 7
Score : 200 points
Problem Statement
N horses numbered 1 to N had a race.
All horses started simultaneously, and horse i took T_i seconds from the start to the goal.
Find the numbers of the horses that finished in 1st, 2nd, and 3rd places. It is guaranteed that all T_i are distinct.
Constraints
- 3\leq N \leq 32
- 1\leq T_i \leq 200
- All T_i are distinct.
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N T_1 \dots T_N
Output
Output the numbers of the horses that finished in 1st, 2nd, and 3rd places, in this order, separated by spaces.
Sample Input 1
4 100 110 105 95
Sample Output 1
4 1 3
The horses finished in the order 4, 1, 3, 2. Output the numbers for 1st, 2nd, and 3rd places, which are 4, 1, 3, in this order, separated by spaces.
Sample Input 2
8 72 74 69 70 73 75 71 77
Sample Output 2
3 4 7
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 300 点
問題文
長さ N の整数列 A があり、最初 A_i = i です。 以下のクエリを全部で Q 個処理してください。
- タイプ 1 : A_p を x に変更する。
- タイプ 2 : A_p を出力する。
- タイプ 3 : 「 A の先頭の要素を末尾にする」という操作を k 回繰り返す。
- 厳密には、 A を (A_2,A_3,\dots,A_N,A_1) に置き換えることを k 回繰り返す。
制約
- 入力は全て整数
- 1 \le N \le 10^6
- 1 \le Q \le 3 \times 10^5
- 全てのクエリは以下の制約を満たす
- 1 \le p \le N
- 1 \le x \le 10^6
- 1 \le k \le 10^9
入力
入力は以下の形式で標準入力から与えられる。
N Q
\rm{Query}_1
\rm{Query}_2
\vdots
\rm{Query}_Q
但し、 \rm{Query}_i は i 個目のクエリを表す。
タイプ 1 のクエリは以下の形式で与えられる。
1 p x
タイプ 2 のクエリは以下の形式で与えられる。
2 p
タイプ 3 のクエリは以下の形式で与えられる。
3 k
出力
タイプ 2 のクエリが現れる度に、その解答を 1 行に出力せよ。
入力例 1
5 5 2 3 1 2 1000000 3 4 2 2 2 3
出力例 1
3 1 1000000
この入力には 5 個のクエリが含まれます。
- 最初、 A=(1,2,3,4,5) です。
- 1 番目のクエリはタイプ 2 で、 A_3=3 を出力します。
- 2 番目のクエリはタイプ 1 で、 A_2=1000000 に置き換えます。
- クエリの結果、 A=(1,1000000,3,4,5) となります。
- 3 番目のクエリはタイプ 3 で、「 A の先頭の要素を末尾にする」という操作を 4 回繰り返します。
- クエリの結果、 A=(5,1,1000000,3,4) となります。
- 4 番目のクエリはタイプ 2 で、 A_2=1 を出力します。
- 5 番目のクエリはタイプ 2 で、 A_3=1000000 を出力します。
入力例 2
1000000 2 1 1000000 999999 3 1000000000
出力例 2
出力が空である場合もあります。
Score : 300 points
Problem Statement
There is an integer sequence A of length N, initially A_i = i. Process a total of Q queries of the following types:
- Type 1: Change A_p to x.
- Type 2: Output A_p.
- Type 3: Repeat the operation "move the first element of A to the end" k times.
- Formally, replace A with (A_2,A_3,\dots,A_N,A_1) k times.
Constraints
- All input values are integers.
- 1 \le N \le 10^6
- 1 \le Q \le 3 \times 10^5
- All queries satisfy the following constraints:
- 1 \le p \le N
- 1 \le x \le 10^6
- 1 \le k \le 10^9
Input
The input is given from Standard Input in the following format:
N Q
\rm{Query}_1
\rm{Query}_2
\vdots
\rm{Query}_Q
Here, \rm{Query}_i represents the i-th query.
Type 1 queries are given in the following format:
1 p x
Type 2 queries are given in the following format:
2 p
Type 3 queries are given in the following format:
3 k
Output
For each Type 2 query, output the answer on a line.
Sample Input 1
5 5 2 3 1 2 1000000 3 4 2 2 2 3
Sample Output 1
3 1 1000000
This input contains 5 queries.
- Initially, A=(1,2,3,4,5).
- The 1st query is Type 2: output A_3=3.
- The 2nd query is Type 1: replace A_2 with 1000000.
- After the query, A=(1,1000000,3,4,5).
- The 3rd query is Type 3: repeat the operation "move the first element of A to the end" 4 times.
- After the query, A=(5,1,1000000,3,4).
- The 4th query is Type 2: output A_2=1.
- The 5th query is Type 2: output A_3=1000000.
Sample Input 2
1000000 2 1 1000000 999999 3 1000000000
Sample Output 2
The output may be empty.