実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 100 点
問題文
N 個の整数 A_1,A_2,\dots,A_N が与えられます。
N 個の整数を合計した値を求めてください。
制約
- 1 \le N \le 100
- 1 \le A_i \le 100
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N A_1 A_2 \dots A_N
出力
答えを出力せよ。
入力例 1
3 2 7 2
出力例 1
11
3 個の整数 2,7,2 が与えられます。
答えは 2 + 7 + 2 = 11 です。
入力例 2
1 3
出力例 2
3
Score : 100 points
Problem Statement
You are given N integers A_1,A_2,\dots, and A_N.
Find the sum of the N integers.
Constraints
- 1 \le N \le 100
- 1 \le A_i \le 100
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
N A_1 A_2 \dots A_N
Output
Print the answer.
Sample Input 1
3 2 7 2
Sample Output 1
11
You are given three integers: 2, 7, and 2.
The answer is 2 + 7 + 2 = 11.
Sample Input 2
1 3
Sample Output 2
3
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 100 点
問題文
N 以下の非負整数を大きい方から順にすべて出力してください。
制約
- 1 \leq N \leq 100
- N は整数
入力
入力は以下の形式で標準入力から与えられる。
N
出力
N 以下の非負整数が X 個存在するとき、X 行出力せよ。
i=1,2,\ldots,X に対し、i 行目には N 以下の非負整数のうち大きい方から i 番目のものを出力せよ。
入力例 1
3
出力例 1
3 2 1 0
3 以下の非負整数は 0,1,2,3 の 4 個です。
1 行目に 3 を、2 行目に 2 を、3 行目に 1 を、4 行目に 0 を出力することでこれらを大きい方から順に出力したことになります。
入力例 2
22
出力例 2
22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Score : 100 points
Problem Statement
Print all non-negative integers less than or equal to N in descending order.
Constraints
- 1 \leq N \leq 100
- N is an integer.
Input
The input is given from Standard Input in the following format:
N
Output
Print X lines, where X is the number of non-negative integers less than or equal to N.
For each i=1, 2, \ldots, X, the i-th line should contain the i-th greatest non-negative integer less than or equal to N.
Sample Input 1
3
Sample Output 1
3 2 1 0
We have four non-negative integers less than or equal to 3, which are 0, 1, 2, and 3.
To print them in descending order, print 3 in the first line, 2 in the second, 1 in the third, and 0 in the fourth.
Sample Input 2
22
Sample Output 2
22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 250 点
問題文
. および # からなる文字列 S が与えられます。
以下の条件を全て満たす文字列 T のうち、 o の文字数が最大となるものを一つ求めてください。
- T の長さは S の長さと等しい。
- T は
.、#、oからなる。 - S_i=
#であるとき、またそのときに限り T_i=#である。 - T_i=T_j=
o(i < j) ならば、 T_{i+1},\ldots,T_{j-1} の中に#が 1 つ以上存在する。
制約
- S は
.および#からなる長さ 1 以上 100 以下の文字列
入力
入力は以下の形式で標準入力から与えられる。
S
出力
条件を全て満たす文字列 T のうち、 o の文字数が最大となるものを一つ出力せよ。
そのような文字列が複数ある場合、どれを出力しても正答となる。
入力例 1
#..#.
出力例 1
#o.#o
T= #o.#o とすると全ての条件を満たすことが確認できます。
全ての条件を満たす T であって、 o の文字数が 2 より多い文字列は存在しないので #o.#o を出力すると正答となります。
この他にも #.o#o を出力しても正答となります。
入力例 2
#
出力例 2
#
入力例 3
.....
出力例 3
..o..
この他にも o....、.o...、...o.、....o を出力しても正答となります。
入力例 4
...#..#.##.#.
出力例 4
o..#.o#o##o#o
Score : 250 points
Problem Statement
You are given a string S consisting of . and #.
Among all strings T that satisfy all of the following conditions, find one with the maximum number of os.
- The length of T is equal to the length of S.
- T consists of
.,#, oro. - T_i=
#if and only if S_i=#. - If T_i=T_j=
o(i < j), then there exists at least one#among T_{i+1},\ldots,T_{j-1}.
Constraints
- S is a string consisting of
.and#with length between 1 and 100, inclusive.
Input
The input is given from Standard Input in the following format:
S
Output
Output one string with the maximum number of os among all strings T that satisfy all conditions.
If there are multiple such strings, printing any of them will be considered correct.
Sample Input 1
#..#.
Sample Output 1
#o.#o
Setting T= #o.#o satisfies all conditions.
There is no string T that satisfies all conditions and has more than two os, so outputting #o.#o is correct.
Outputting #.o#o is also correct.
Sample Input 2
#
Sample Output 2
#
Sample Input 3
.....
Sample Output 3
..o..
Outputting o...., .o..., ...o., or ....o is also correct.
Sample Input 4
...#..#.##.#.
Sample Output 4
o..#.o#o##o#o
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 200 点
問題文
AtCoder 遊園地には K 人乗りのアトラクションがあります。 現在、このアトラクションの待機列には N グループが並んでいます。
先頭から i 番目 (1\leq i\leq N) のグループは A _ i 人組です。 すべての i (1\leq i\leq N) について、A _ i\leq K です。
高橋君はこのアトラクションのスタッフとして、並んでいるグループを次の手順に従って誘導します。
はじめ、アトラクションには誰も誘導されておらず、空席は K 個あります。
- 待機列に並んでいるグループがない場合、アトラクションをスタートさせ、誘導を終了する。
- アトラクションの空席の数と待機列の先頭に並んでいるグループの人数を比較し、次のどちらかを行う。
- 待機列の先頭に並んでいるグループの人数よりアトラクションの空席の数のほうが少ない場合、アトラクションをスタートさせる。 スタートしたのち、アトラクションの空席が K 個になる。
- そうでない場合、待機列の先頭に並んでいるグループを全員アトラクションへ誘導する。 先頭のグループが待機列から取り出され、アトラクションの空席がグループの人数ぶんだけ減少する。
- 1 に戻る。
ただし、誘導を開始したあとに追加でグループが並ぶことはないとします。 以上の条件のもとで、この手順が有限回で終了することが示せます。
高橋君が誘導を開始してから誘導を終了するまで、何回アトラクションをスタートさせるか求めてください。
制約
- 1\leq N\leq100
- 1\leq K\leq100
- 1\leq A _ i\leq K\ (1\leq i\leq N)
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N K A _ 1 A _ 2 \ldots A _ N
出力
答えを出力せよ。
入力例 1
7 6 2 5 1 4 1 2 3
出力例 1
4
はじめ、7 つのグループは以下のように並んでいます。

高橋君の誘導の様子の一部を以下の図に示します。

- はじめ、先頭に並んでいるグループは 2 人のグループで、空席は 6 個です。よって、高橋君は先頭のグループをアトラクションに誘導し、空席は 4 個になります。
- 次に、先頭に並んでいるグループは 5 人のグループで、空席の個数 4 より多いため、アトラクションをスタートさせます。
- 空席が 6 個になったため、先頭のグループをアトラクションに誘導し、空席は 1 個になります。
- 次に先頭に並んでいるのは 1 人なので、アトラクションに誘導し、空席は 0 個になります。
すべての誘導が終了するまでに、高橋君は 4 回アトラクションをスタートさせることになります。
よって、4 を出力してください。

入力例 2
7 10 1 10 1 10 1 10 1
出力例 2
7
入力例 3
15 100 73 8 55 26 97 48 37 47 35 55 5 17 62 2 60
出力例 3
8
Score: 200 points
Problem Statement
The AtCoder amusement park has an attraction that can accommodate K people. Now, there are N groups lined up in the queue for this attraction.
The i-th group from the front (1\leq i\leq N) consists of A_i people. For all i (1\leq i\leq N), it holds that A_i \leq K.
Takahashi, as a staff member of this attraction, will guide the groups in the queue according to the following procedure.
Initially, no one has been guided to the attraction, and there are K empty seats.
- If there are no groups in the queue, start the attraction and end the guidance.
- Compare the number of empty seats in the attraction with the number of people in the group at the front of the queue, and do one of the following:
- If the number of empty seats is less than the number of people in the group at the front, start the attraction. Then, the number of empty seats becomes K again.
- Otherwise, guide the entire group at the front of the queue to the attraction. The front group is removed from the queue, and the number of empty seats decreases by the number of people in the group.
- Go back to step 1.
Here, no additional groups will line up after the guidance has started. Under these conditions, it can be shown that this procedure will end in a finite number of steps.
Determine how many times the attraction will be started throughout the guidance.
Constraints
- 1\leq N\leq 100
- 1\leq K\leq 100
- 1\leq A_i\leq K\ (1\leq i\leq N)
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N K A_1 A_2 \ldots A_N
Output
Print the answer.
Sample Input 1
7 6 2 5 1 4 1 2 3
Sample Output 1
4
Initially, the seven groups are lined up as follows:

Part of Takahashi's guidance is shown in the following figure:

- Initially, the group at the front has 2 people, and there are 6 empty seats. Thus, he guides the front group to the attraction, leaving 4 empty seats.
- Next, the group at the front has 5 people, which is more than the 4 empty seats, so the attraction is started.
- After the attraction is started, there are 6 empty seats again, so the front group is guided to the attraction, leaving 1 empty seat.
- Next, the group at the front has 1 person, so they are guided to the attraction, leaving 0 empty seats.
In total, he starts the attraction four times before the guidance is completed.
Therefore, print 4.

Sample Input 2
7 10 1 10 1 10 1 10 1
Sample Output 2
7
Sample Input 3
15 100 73 8 55 26 97 48 37 47 35 55 5 17 62 2 60
Sample Output 3
8
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 300 点
問題文
高橋君はゲームをしています。このゲームには 1 から N の番号がついた N 個のスキルがあります。
N 個の整数の組 (A_1,B_1), \dots,(A_N,B_N) が与えられます。
(A_i,B_i)=(0,0) のとき高橋君はスキル i を習得済みです。
そうでないとき、スキル A_i,B_i の少なくとも一方を習得済みのときかつそのときに限りスキル i を習得することができます。
既に取得済みのスキルも含め、高橋君が最終的に習得することができるスキルの個数を求めてください。
制約
- 1\leq N \leq 2\times 10^5
- (A_i,B_i)=(0,0) または 1\leq A_i,B_i \leq N
- 入力は全て整数
入力
入力は以下の形式で標準入力から与えられる。
N A_1 B_1 A_2 B_2 \vdots A_N B_N
出力
答えを出力せよ。
入力例 1
6 0 0 1 3 3 2 5 5 4 6 6 4
出力例 1
3
最初、高橋君はスキル 1 を習得済みです。スキル 1 を習得済みのためスキル 2 を習得することができ、スキル 2 を習得したことでスキル 3 を習得できます。
スキル 4,5,6 を習得することはできないため、答えは 3 となります。
入力例 2
4 0 0 0 0 0 0 0 0
出力例 2
4
Score : 300 points
Problem Statement
Takahashi is playing a game. This game has N skills numbered 1 through N.
You are given N pairs of integers (A_1,B_1), \dots,(A_N,B_N).
If (A_i,B_i)=(0,0), then Takahashi has already learned skill i.
Otherwise, Takahashi can learn skill i if and only if at least one of skills A_i and B_i has already been learned.
Including the skills already learned, find the number of skills that Takahashi can ultimately learn.
Constraints
- 1\leq N \leq 2\times 10^5
- (A_i,B_i)=(0,0) or 1\leq A_i,B_i \leq N
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N A_1 B_1 A_2 B_2 \vdots A_N B_N
Output
Output the answer.
Sample Input 1
6 0 0 1 3 3 2 5 5 4 6 6 4
Sample Output 1
3
At first, Takahashi has already learned skill 1. Because skill 1 has been learned, skill 2 can be learned, and learning skill 2 enables learning skill 3. Since it is impossible to learn skills 4,5,6, the answer is 3.
Sample Input 2
4 0 0 0 0 0 0 0 0
Sample Output 2
4
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 300 点
問題文
整数 N が与えられるので、以下の条件を全て満たす整数 X の個数を 998244353 で割った余りを求めてください。
- N 桁の正整数である。
- X の各桁を上の位から順に X_1,X_2,\dots,X_N とする。このとき以下の条件を全て満たす。
- 全ての整数 1 \le i \le N に対して、 1 \le X_i \le 9
- 全ての整数 1 \le i \le N-1 に対して、 |X_i-X_{i+1}| \le 1
制約
- N は整数
- 2 \le N \le 10^6
入力
入力は以下の形式で標準入力から与えられる。
N
出力
答えを整数として出力せよ。
入力例 1
4
出力例 1
203
4 桁の整数として、例えば 1111,1234,7878,6545 が問題文中の条件を満たします。
入力例 2
2
出力例 2
25
入力例 3
1000000
出力例 3
248860093
998244353 で割った余りを求めることに注意してください。
Score : 300 points
Problem Statement
Given an integer N, find the number of integers X that satisfy all of the following conditions, modulo 998244353.
- X is an N-digit positive integer.
- Let X_1,X_2,\dots,X_N be the digits of X from top to bottom. They satisfy all of the following:
- 1 \le X_i \le 9 for all integers 1 \le i \le N;
- |X_i-X_{i+1}| \le 1 for all integers 1 \le i \le N-1.
Constraints
- N is an integer.
- 2 \le N \le 10^6
Input
Input is given from Standard Input in the following format:
N
Output
Print the answer as an integer.
Sample Input 1
4
Sample Output 1
203
Some of the 4-digit integers satisfying the conditions are 1111,1234,7878,6545.
Sample Input 2
2
Sample Output 2
25
Sample Input 3
1000000
Sample Output 3
248860093
Be sure to find the count modulo 998244353.
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 400 点
問題文
正整数 N, M, K が与えられます。ここで、N と M は異なります。
正の整数であって、N と M のうち ちょうど一方のみ で割り切れる数のうち小さい方から K 番目のものを出力してください。
制約
- 1\leq N, M\leq 10^8
- 1\leq K\leq 10^{10}
- N\neq M
- N, M, K は整数
入力
入力は以下の形式で標準入力から与えられる。
N M K
出力
N と M のうちちょうど一方のみで割り切れる正整数のうち小さい方から K 番目のものを出力せよ。
入力例 1
2 3 5
出力例 1
9
2 と 3 のうちちょうど一方のみで割り切れる正整数は小さい方から順に 2,3,4,8,9,10,\ldots です。
ここで、6 は 2 と 3 の両方で割り切れるため条件をみたさないことに注意してください。
条件をみたす正整数のうち小さい方から 5 番目の数は 9 であるため、9 を出力します。
入力例 2
1 2 3
出力例 2
5
条件をみたす数は小さい方から順に 1,3,5,7,\ldots です。
入力例 3
100000000 99999999 10000000000
出力例 3
500000002500000000
Score: 400 points
Problem Statement
You are given three positive integers N, M, and K. Here, N and M are different.
Print the K-th smallest positive integer divisible by exactly one of N and M.
Constraints
- 1 \leq N, M \leq 10^8
- 1 \leq K \leq 10^{10}
- N \neq M
- N, M, and K are integers.
Input
The input is given from Standard Input in the following format:
N M K
Output
Print the K-th smallest positive integer divisible by exactly one of N and M.
Sample Input 1
2 3 5
Sample Output 1
9
The positive integers divisible by exactly one of 2 and 3 are 2, 3, 4, 8, 9, 10, \ldots in ascending order.
Note that 6 is not included because it is divisible by both 2 and 3.
The fifth smallest positive integer that satisfies the condition is 9, so we print 9.
Sample Input 2
1 2 3
Sample Output 2
5
The numbers that satisfy the condition are 1, 3, 5, 7, \ldots in ascending order.
Sample Input 3
100000000 99999999 10000000000
Sample Output 3
500000002500000000
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 450 点
問題文
あけましておめでとうございます!正月の外遊びといえば凧揚げですね!
1 から N の番号がついた N 人の人が河原で凧揚げをしようとしています。
河原に面する川は直線状に流れているので、以降では川の方向を x 軸、高さ方向を y 軸とする 2 次元座標で考えます。
人 i は地点 (A_i, 0) に立って地点 (B_i, 1) に凧を揚げようとしています。
しかし、人や凧の衝突、および凧糸が絡まることを避けるため、以下の条件を満たす時、人 i と人 j (i \neq j) は同時に凧を揚げることは出来ません。
- 「(A_i, 0) と (B_i, 1) を結ぶ線分」と「(A_j, 0) と (B_j, 1) を結ぶ線分」が交点を持つ。(線分の端点同士が接する場合も含む。)
以上の制約を守った上で、最大で何人が同時に凧を揚げることが出来ますか?
制約
- 1 \leq N \leq 2\times 10^5
- 0 \leq A_i \leq 10^9
- 0 \leq B_i \leq 10^9
- 入力される値は全て整数
入力
入力は以下の形式で標準入力から与えられる。
N A_1 B_1 A_2 B_2 \vdots A_N B_N
出力
同時に凧を揚げることが出来る人数の最大値を出力せよ。
入力例 1
3 3 5 1 4 2 6
出力例 1
2
人 1 と人 2 、および人 2 と人 3 は同時に凧を揚げることが出来ますが、人 1 と人 3 は同時に凧を揚げることが出来ません。
よって、適切な組み合わせを選べば 2 人が同時に凧を揚げられる一方で、3 人が同時に凧を揚げることは不可能です。よって答えは 2 人です。
入力例 2
5 1 2 1 3 1 4 1 5 1 6
出力例 2
1
入力例 3
10 440423913 766294629 725560240 59187619 965580535 585990756 550925213 623321125 549392044 122410708 21524934 690874816 529970099 244587368 757265587 736247509 576136367 993115118 219853537 21553211
出力例 3
4
Score : 450 points
Problem Statement
Happy New Year! When it comes to outdoor play on New Year's, it's kite flying!
N people numbered 1 to N are trying to fly kites by the riverbank.
The river facing the riverbank flows in a straight line, so from now on, we consider a two-dimensional coordinate system where the x-axis is the direction of the river and the y-axis is the height direction.
Person i is standing at point (A_i, 0) and trying to fly a kite at point (B_i, 1).
However, to avoid collisions of people and kites, and to avoid kite strings getting tangled, persons i and j (i \neq j) cannot fly kites at the same time if the following condition is satisfied:
- The "line segment connecting (A_i, 0) and (B_i, 1)" and the "line segment connecting (A_j, 0) and (B_j, 1)" have an intersection point. (This includes the case where the endpoints of the line segments touch each other.)
What is the maximum number of people who can fly kites at the same time while respecting the above constraint?
Constraints
- 1 \leq N \leq 2\times 10^5
- 0 \leq A_i \leq 10^9
- 0 \leq B_i \leq 10^9
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N A_1 B_1 A_2 B_2 \vdots A_N B_N
Output
Output the maximum number of people who can fly kites at the same time.
Sample Input 1
3 3 5 1 4 2 6
Sample Output 1
2
Persons 1 and 2, as well as persons 2 and 3, can fly kites at the same time, but persons 1 and 3 cannot fly kites at the same time.
Therefore, two people, if chosen appropriately, can fly kites at the same time, while it is impossible for three people to fly kites at the same time. Thus, the answer is 2.
Sample Input 2
5 1 2 1 3 1 4 1 5 1 6
Sample Output 2
1
Sample Input 3
10 440423913 766294629 725560240 59187619 965580535 585990756 550925213 623321125 549392044 122410708 21524934 690874816 529970099 244587368 757265587 736247509 576136367 993115118 219853537 21553211
Sample Output 3
4
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 500 点
問題文
N 個の箱 1,2,\dots,N と、 10^{100} 個のボール 1,2,\dots,10^{100} があります。 最初、箱 i にはボール i のみが入っています。
ここに以下の操作が合計 Q 回行われるので、処理してください。
操作にはタイプ 1,2,3 の 3 種類があります。
タイプ 1 : 箱 X に箱 Y の中身を全て入れる。 この操作では X \neq Y が保証される。
1 X Y
タイプ 2 : 現在いずれかの箱に入っているボールの数の合計を k とすると、箱 X にボール k+1 を入れる。
2 X
タイプ 3 : ボール X が入っている箱の番号を答える。
3 X
制約
- 入力は全て整数
- 2 \le N \le 3 \times 10^5
- 1 \le Q \le 3 \times 10^5
- タイプ 1 の操作について、 1 \le X,Y \le N かつ X \neq Y
- タイプ 2 の操作について、 1 \le X \le N
- タイプ 3 の操作について、その時点でボール X がいずれかの箱に入っている
- タイプ 3 の操作が少なくとも 1 つ与えられる
入力
入力は以下の形式で標準入力から与えられる。
但し、 op_i は i 回目の操作を表す。
N Q op_1 op_2 \vdots op_Q
出力
各タイプ 3 の操作に対して、答えを 1 行に 1 つ、整数として出力せよ。
入力例 1
5 10 3 5 1 1 4 2 1 2 4 3 7 1 3 1 3 4 1 1 4 3 7 3 6
出力例 1
5 4 3 1 3
この入力は 10 個の操作を含みます。
- 1 回目の操作はタイプ 3 です。ボール 5 は箱 5 に入っています。
- 2 回目の操作はタイプ 1 です。箱 1 に箱 4 の中身を全て入れます。
- 箱 1 の中身はボール 1,4 、箱 4 の中身は空になります。
- 3 回目の操作はタイプ 2 です。箱 1 にボール 6 を入れます。
- 4 回目の操作はタイプ 2 です。箱 4 にボール 7 を入れます。
- 5 回目の操作はタイプ 3 です。ボール 7 は箱 4 に入っています。
- 6 回目の操作はタイプ 1 です。箱 3 に箱 1 の中身を全て入れます。
- 箱 3 の中身はボール 1,3,4,6 、箱 1 の中身は空になります。
- 7 回目の操作はタイプ 3 です。ボール 4 は箱 3 に入っています。
- 8 回目の操作はタイプ 1 です。箱 1 に箱 4 の中身を全て入れます。
- 箱 1 の中身はボール 7 、箱 4 の中身は空になります。
- 9 回目の操作はタイプ 3 です。ボール 7 は箱 1 に入っています。
- 10 回目の操作はタイプ 3 です。ボール 6 は箱 3 に入っています。
Score : 500 points
Problem Statement
There are N boxes numbered 1,2,\ldots,N, and 10^{100} balls numbered 1,2,\dots,10^{100}. Initially, box i contains just ball i.
Process a total of Q operations that will be performed.
There are three types of operations: 1, 2, and 3.
Type 1: Put all contents of box Y into box X. It is guaranteed that X \neq Y.
1 X Y
Type 2: Put ball k+1 into box X, where k is the current total number of balls contained in the boxes.
2 X
Type 3: Report the number of the box that contains ball X.
3 X
Constraints
- All values in the input are integers.
- 2 \le N \le 3 \times 10^5
- 1 \le Q \le 3 \times 10^5
- For each type-1 operation, 1 \le X,Y \le N and X \neq Y.
- For each type-2 operation, 1 \le X \le N.
- For each type-3 operation, ball X is contained in some box at that point.
- There is at least one type-3 operation.
Input
The input is given from Standard Input in the following format.
Here, op_i represents the i-th operation.
N Q op_1 op_2 \vdots op_Q
Output
For each type-3 operation, print a line containing the response as an integer.
Sample Input 1
5 10 3 5 1 1 4 2 1 2 4 3 7 1 3 1 3 4 1 1 4 3 7 3 6
Sample Output 1
5 4 3 1 3
This input contains ten operations.
- The first operation is of type 3. Ball 5 is in box 5.
- The second operation is of type 1. Put all contents of box 4 into box 1.
- Box 1 now contains balls 1 and 4, and box 4 is now empty.
- The third operation is of type 2. Put ball 6 into box 1.
- The fourth operation is of type 2. Put ball 7 into box 4.
- The fifth operation is of type 3. Ball 7 is in box 4.
- The sixth operation is of type 1. Put all contents of box 1 into box 3.
- Box 3 now contains balls 1, 3, 4, and 6, and box 1 is now empty.
- The seventh operation is of type 3. Ball 4 is in box 3.
- The eighth operation is of type 1. Put all contents of box 4 into box 1.
- Box 1 now contains ball 7, and box 4 is now empty.
- The ninth operation is of type 3. Ball 7 is in box 1.
- The tenth operation is of type 3. Ball 6 is in box 3.