A - Efficient Signal Control Editorial /

Time Limit: 3 sec / Memory Limit: 1024 MiB

問題文

Y国には N 個の都市と M 本の道路があり、i 番目の道路は都市 u_i と都市 v_i を双方向に結んでいる。どの道路も交差はなく、都市と道路からなるグラフは平面グラフである。

各都市には、その都市へと入る交通を制御するための信号がある。 信号にはまたは2 つの状態があり、都市 v の信号が青である場合のみ、都市 v へと移動できる。(移動元の都市の信号はどちらでも良い)

Y国の都市の信号は、配列 A, B によって一元管理されている。

配列 A は長さ L_A であり、各要素は 0 以上 N-1 以下の整数である。
配列 B は長さ L_B であり、初期状態は、すべての要素が -1 である。

特に、配列 B は信号の状態を表す配列であり、配列 B が値 v を要素として含むとき、都市 v の信号は青である。配列 B が値 v を要素として含まないとき、都市 v の信号は赤である。
配列 A は、配列 B の制御に用いる配列であり、以下のように操作することで配列 A の値を用いて配列 B の内容を変更し、信号の状態を変化させることが出来る。

  1. A から連続する領域を選び、その領域を R_A とする。
  2. B から、R_A と同じ長さの連続する領域を選び、その領域を R_B とする。
  3. R_B の内容を、R_A の内容で上書きする。

さて、旅行好きなXは、Y国を旅行する計画を立てている。
Xは旅行計画として、都市の頂点番号のリスト t_0, t_1, \ldots, t_{T-1} を持っており、これらの都市を順に訪問したいと考えている。リストの中には同じ都市が複数回含まれる場合もあるが、同じ都市が連続して含まれることはない。

Xは都市 0 を現在位置として、旅を始める。まず初めに、Xは友人であるY国の交通大臣に依頼し、信号の制御に用いる配列 A の内容を好きな値に設定する。 これ以降、A の内容を変更することはできない。
その後、次の 信号操作 または 移動 を好きな順序で 10^5 回以下の好きな回数繰り返す。信号操作と移動の具体例については下部の「出力例」セクションも参照せよ。

  • 信号操作
    • Y国の交通大臣に依頼し、上述した信号に対する操作を 1 回行い、信号の状態を変化させる。
  • 移動
    • Xの現在位置である都市から直接道路でつながっている都市の 1 つに移動し、現在位置を移動先の都市に更新する。移動先の都市の信号は青である必要がある。

旅行計画にある都市すべてをリストの順序で訪れることができた場合、Xの旅行は成功となる。
より厳密には、Xの現在位置となった都市を順に c_0 = 0, c_1, \ldots としたとき、ある狭義単調増加な長さ T の非負整数列 (i_0, i_1, \ldots, i_{T-1}) であって c_{i_j} = t_j(0 \le j \le T - 1) であるようなものが存在する場合、またその場合に限り、Xの旅行は成功となる。

Y国の交通大臣は非常に多忙なため、Xは信号操作の回数をなるべく減らしたいと考えている。
配列 A の要素の決定と信号操作・移動をうまく行い、できるだけ少ない信号操作の回数で旅を成功させてほしい。


得点

旅行が成功したときの信号操作の回数が C のとき、C の絶対スコアが得られる。絶対スコアは小さければ小さいほどよい。

旅行が成功しなかった場合、不正な信号操作/移動を行った場合、信号操作と移動を行った回数が 10^5 回を超えた場合は WA と判定される。

各テストケース毎に、 \( \text{round}(10^9 \times \left(\frac{全参加者中の最小絶対スコア}{自身の絶対スコア}\right)) \) の相対評価スコアが得られ、その和が提出の得点となる。

最終順位はコンテスト終了後に実施されるより多くの入力に対するシステムテストにおける得点で決定される。 暫定テスト、システムテストともに、一部のテストケースで不正な出力や制限時間超過をした場合、そのテストケースの相対評価スコアは0点となり、そのテストケースにおいては「全参加者中の最小絶対スコア」の計算から除外される。 システムテストは CE 以外の結果を得た一番最後の提出に対してのみ行われるため、最終的に提出する解答を間違えないよう注意せよ。

テストケース数

  • 暫定テスト: 50個
  • システムテスト: 2000個
    • コンテスト終了後に seeds.txt (sha256=607aca150bd5f8f062937b02e6d14c15f7661aefbd279f150043e6d7e47f8d3c) を公開します。

相対評価システムについて

暫定テスト・システムテストともに、CE 以外の結果を得た一番最後の提出のみが順位表に反映されます。
相対評価スコアの計算に用いられる各テストケース毎の全参加者中の最小絶対スコアの算出についても、順位表に反映されている最終提出のみが用いられます。

順位表に表示されているスコアは相対評価スコアであり、新規提出があるたびに、相対評価スコアが再計算されます。 一方、提出一覧から確認出来る各提出のスコアは各テストケース毎の絶対スコアをそのまま足し合わせたものであり、相対評価スコアは表示されません。 最新以外の提出の、現在の順位表における相対評価スコアを知るためには、再提出が必要です。 不正な出力や制限時間超過をした場合、提出一覧から確認出来るスコアは0となりますが、順位表には正解したテストケースに対する相対評価スコアの和が表示されます。

実行時間について

実行時間には多少のブレが生じます。 また、システムテストでは同時に大量の実行を行うため、暫定テストに比べて数%程度実行時間が伸びる現象が確認されています。 そのため、実行時間制限ギリギリの提出がシステムテストで TLE となる可能性があります。 プログラム内で時間を計測して処理を打ち切るか、実行時間に余裕を持たせるようお願いします。


入力

入力は以下の形式で標準入力から与えられる。

\(
N ~ M ~ T ~ L_A ~ L_B \\
u_0 ~ v_0 \\
\vdots \\
u_{M-1} ~ v_{M-1} \\
t_{0} ~ t_{1} ~ \ldots ~ t_{T-1} \\
x_0 ~ y_0 \\
\vdots \\
x_{N-1} ~ y_{N-1} \)
  • 1行目には5つの整数 N,M,T,L_A,L_B がスペース区切りで与えられる。
    • N は都市の数で、N = 600 を満たす。
    • M は道路の本数で、N-1 \le M \le 3 \times N-6 を満たす。
    • T は訪問する都市の数で、T = 600 を満たす。
    • L_A は信号の制御に用いる配列 A の長さで、N \le L_A \le 2 \times N を満たす。
    • L_B は信号の制御に用いる配列 B の長さで、4 \le L_B \le 24 を満たす。
  • 続く M 行は道路の情報で、道路 i は 都市 u_iv_i を双方向に結ぶ。 u_i, v_i は、0 \le u_i \lt v_i \le N - 1, (u_i, v_i) \neq (u_j, v_j) (i \neq j) を満たす。
  • 次く1行に、T 個の整数値がスペース区切りで与えられる。t_0, t_1, ..., t_{T - 1} は、Xが訪れる予定の都市であり、 0 \le t_i \le N - 1 (0 \le i \le T - 1), t_0 \neq 0, t_i \neq t_{i+1} (0 \le i \le T - 2) を満たす。
  • 続く N 行は、ビジュアライザのため、都市 i の座標が (x_i, y_i) として与えられる。座標の値は整数であり、 0 \le x_i, y_i \le 1000, (x_i, y_i) \neq (x_j, y_j) (i \neq j) を満たす。不要であれば読み込まなくても構わない。
与えられるグラフは、連結な平面グラフであり、頂点 i を座標 (x_i, y_i) に配置し、各辺を両端点を結ぶ線分として描画した時、どの二辺も端点以外に共通点を持たないことが保証されている。

出力

1行目に、A の初期値を表す L_A 個の 0 以上 N - 1 以下の整数をスペース区切りで出力せよ。

続く各行に、以下のフォーマットで行動を出力せよ。

  • 信号操作を行う場合
    R_A, R_B の長さを l (1 \le l \le L_B)R_A の開始位置を P_A (0 \le P_A \le L_A - l)R_B の開始位置を P_B (0 \le P_B \le L_B - l) としたとき、以下のように、行頭の s に続けてスペース区切りで l, P_A, P_B を出力せよ。
    l P_A P_B
  • 移動を行う場合
    移動先の都市の番号を v としたとき、 以下のように、行頭の m に続けてスペース区切りで v を出力せよ。
    v
    移動先の都市は現在の都市と直接道路で繋がっており、信号はこの時点で青である必要があることに注意せよ。

例を見る

入力生成方法

入力生成方法の詳細

L 以上 U 以下の整数を一様ランダムに生成する関数を \mathrm{rand}(L, U) とし、 L 以上 U 未満の実数を一様ランダムに生成する関数を \mathrm{rand\_double}(L, U) とする。 また、2つの頂点 u, v の距離を \sqrt{(x_u - x_v)^2 + (y_u - y_v)^2} とする。

グラフの生成

グラフの生成に使用するパラメタ D_{vmin}, D_{emax}, P_{remove} を、それぞれ \mathrm{rand}(20, 30), \mathrm{rand}(80, 140), \mathrm{rand\_double}(0.0, 0.5) で生成する。

N = 600 として、i = 0, 1, \ldots N - 1 の順に以下の操作を行い頂点集合 V を生成する。

  1. x_i = \mathrm{rand}(0,1000), y_i = \mathrm{rand}(0,1000) として生成する。
  2. V に含まれる頂点に (x_i, y_i) との距離が D_{vmin} 未満のものが存在しなくなるまで、(x_i, y_i) を選び直す。
  3. V(x_i, y_i) を加える。

辺集合 E を以下のようにして生成する。

  1. 距離が D_{emax} / 2 以下の頂点ペアを全て列挙し、ランダムな順番に並び替える。各ペアについて順番に、すでに追加したどの辺とも交差しない場合 E に追加する。ここで、辺が交差するとは、頂点 i を座標 (x_i, y_i) に配置し、辺を両端点を結ぶ線分として描画した際に、2辺が共通の端点以外に共通点を持つことを表す。
  2. 距離が D_{emax} / 2 より大きく D_{emax} 以下であるような頂点ペアを全て列挙し、ランダムな順番に並び替える。各ペアについて順番に、すでに追加したどの辺とも交差しない場合に E に追加する。

この時点でグラフ (V, E) が連結でなければ V の生成からやり直す。

最後に、各辺 e \in E についてランダムな順に、e を取り除いてもグラフが連結であれば、確率 P_{remove}E から e を取り除く。

t の生成

t_0\mathrm{rand}(1, N - 1) で生成する。

i = 1, 2, \ldots, T - 1 の順に、t_i を、0 以上 N - 1 以下の整数のうち t_{i -1} 以外のものの中から一様ランダムに選ぶことで生成する。

L_A, L_B の生成

L_A\mathrm{rand}(N, 2 \times N) で生成する。

L_B\mathrm{floor}{(\mathrm{rand\_double}(2.0, 5.0)^2)} で生成する。ここで、\mathrm{floor}{(x)}x 以下の最大の整数を表す。

必ずしも理解する必要はありません。
厳密な実装は入力ジェネレータのソースコードをご覧ください。

ツール

  • Web版ビジュアライザ・入力ジェネレータ: アニメーション表示が可能です。
  • ローカル版テスタ・入力ジェネレータ: 使用するにはRust言語のコンパイル環境をご用意下さい。
  • サンプルコード(C++, Python): サンプルの解答です。次の処理を実装しています。
    • 配列 A の初期値を、先頭 N 個の要素は 0, 1, \ldots, N - 1 に、残りの要素は 0 に設定する。
    • i = 0, 1, \ldots, T - 1 の順に以下を行う。
      • 次の訪問先 t_i とのユークリッド距離が小さいような頂点を優先して探索する深さ優先探索を用いて、現在位置から t_i までの経路を見つける。その経路上の頂点を1つずつ、l = 1, P_B = 0 での信号操作を行って信号を青にしてからその頂点へ移動することを繰り返し、t_i まで移動する。

コンテスト期間中に、ビジュアライズ結果の共有や、解法・考察に関する言及は禁止されています。ご注意下さい。

ローカル版テスタは解答プログラムの出力をそのまま出力ファイルに書き出します。
解答プログラムは、# から始まるコメント行を出力に含めてもかまいません。 Web版ビジュアライザを使用すると、コメント行を対応するタイミングで表示できるため、デバッグや考察等に役立てることができます。 ジャッジプログラムはコメント行を全て無視するため、コメント行を出力するプログラムをそのまま提出可能です。


入力例

7 9 3 7 4
0 1
0 2
0 3
1 2
2 3
3 4
4 5
5 6
6 0
4 1 5
100 0
200 0
200 100
100 100
0 200
0 100
0 0
この入力は説明用のものなので、入力の制約を満たさないことに注意せよ。

出力例

0 1 3 4 5 6 2
s 4 0 0
m 3
m 4
m 3
m 0
m 1
s 2 4 2
m 0
m 6
m 5
出力 説明 ビジュアライズ
0 1 3 4 5 6 2
A の初期値を [0, 1, 3, 4, 5, 6, 2] とする。
初期状態では信号は全て赤である。
s 4 0 0
A0 番目の要素から始まる長さ 4 の部分列を、 B0 番目の要素を始点とする範囲に対して上書きする。 B の値は [0, 1, 3, 4] となる。
m 3
m 4
頂点 0 → 3 → 4 の順で最初の目的地の頂点へと移動する。
m 3
m 0
m 1
4 → 3 → 0 → 1 の順で次の目的地の頂点へと移動する。
s 2 4 2
A4 番目の要素から始まる長さ 2 の部分列を、 B2 番目の要素を始点とする範囲に対して上書きする。 B の値は [0, 1, 5, 6] となる。
m 0
m 6
m 5
頂点 1 → 0 → 6 → 5 の順で最後の目的地の頂点へと移動する。
信号操作を2回行ったので、このテストケースのスコアは 2 となる。

Problem Statement

Country Y has N cities and M roads, where the i-th road connects city u_i and city v_i bidirectionally. None of the roads intersect, and the graph consisting of cities and roads is a planar graph.

Each city has a traffic signal to control the traffic entering the city. The signals have two states: red and green. You can move to city v only if the signal in city v is green. (The signal in the city you are moving from can be in either state.)

The traffic signals of the cities in Country Y are managed by arrays A and B.

Array A has a length of L_A, and each element is an integer between 0 and N-1, inclusive.
Array B has a length of L_B, and initially, all elements are -1.

Specifically, array B represents the state of the traffic signals. If array B contains the value v, then the signal in city v is green. If array B does not contain the value v, then the signal in city v is red.
Array A is used to control array B. By performing the following operations, you can use the values in array A to change the contents of array B and thus change the state of the signals:

  1. Select a contiguous subarray from A and call it R_A.
  2. Select a contiguous subarray from B of the same length as R_A and call it R_B.
  3. Overwrite the contents of R_B with the contents of R_A.

Travel enthusiast X is planning a trip through Country Y.
X has a list of city vertex numbers t_0, t_1, \ldots, t_{T-1} that he wants to visit in order. The same city may appear multiple times in the list, but the same city does not appear consecutively.

X starts the journey from city 0. Initially, X asks his friend, the Minister of Transport of Country Y, to set the contents of array A to any desired values. After this, the contents of array A cannot be changed.
Then, X can repeat the following signal operations or movements up to 10^5 times in any order. See the "Sample Output" section below for specific examples of signal operation and movement.

  • Signal Operation
    • Ask the Minister of Transport of Country Y to perform the signal operation described above once, changing the state of the signals.
  • Movement
    • Move from the current city to one of the cities directly connected by a road, and update the current city to the destination city. The signal in the destination city must be green.

If X can visit all the cities in the travel plan in the order listed, the trip is successful.
More precisely, if there exists a strictly increasing sequence of non-negative integers (i_0, i_1, \ldots, i_{T-1}) of length T such that c_{i_j} = t_j (0 \le j \le T - 1), where the sequence of cities visited by X is c_0 = 0, c_1, \ldots, then the trip is successful.

The Minister of Transport of Country Y is very busy, so X wants to minimize the number of signal operations.
Please determine the elements of array A, and perform signal operations and movements in such a way that the trip is successful with the minimum number of signal operations.


Scoring

When the trip is successful and the number of signal operations is denoted as C, you will receive an absolute score of C. The lower the absolute score, the better.

If the trip is unsuccessful, or if there are invalid signal operations/movements, or if the number of signal operations and movements exceeds 10^5, the result is judged as WA.

For each test case, \( \text{round}(10^9 \times \left(\frac{\rm{minimum\ absolute\ score\ among\ all\ participants}}{\rm{your\ absolute\ score}}\right)) \) relative evaluation score is obtained, and the sum of the relative evaluation scores is the score of the submission.

The final ranking will be determined by the system test with more inputs which will be run after the contest is over. In both the provisional/system test, if your submission produces illegal output or exceeds the time limit for some test cases, only the relative evaluation score for those test cases will be 0, and your submission will be excluded from the calculation of minimum absolute score among all participants for those test cases.

The system test will be performed only for the last submission which received a result other than CE . Be careful not to make a mistake in the final submission.

Number of test cases

  • Provisional test: 50
  • System test: 2000
    • We will publish seeds.txt (sha256=607aca150bd5f8f062937b02e6d14c15f7661aefbd279f150043e6d7e47f8d3c) after the contest is over.

About Relative Evaluation System

In both the provisional/system test, the standings will be calculated using only the last submission which received a result other than CE.
Only the last submissions are used to calculate the minimum absolute score among all participants for each test case when calculating the relative evaluation scores.

The scores shown in the standings are relative, and whenever a new submission arrives, all relative scores are recalculated.
On the other hand, the score for each submission shown on the submissions page is the sum of the evaluation value for each test case, and the relative scores are not shown. In order to know the relative score of submission other than the latest one in the current standings, you need to resubmit it. If your submission produces illegal output or exceeds the time limit for some test cases, the score shown on the submissions page will be 0, but the standings show the sum of the relative scores for the test cases that were answered correctly.

About execution time

Execution time may vary slightly from run to run. In addition, since system tests simultaneously perform a large number of executions, it has been observed that execution time increases by several percent compared to provisional tests. For these reasons, submissions that are very close to the time limit may result in TLE in the system test. Please measure the execution time in your program to terminate the process, or make sure to have enough time margin for the execution.


Input

Input will be provided from Standard Input in the following format.

\(
N ~ M ~ T ~ L_A ~ L_B \\
u_0 ~ v_0 \\
\vdots \\
u_{M-1} ~ v_{M-1} \\
t_{0} ~ t_{1} ~ \ldots ~ t_{T-1} \\
x_0 ~ y_0 \\
\vdots \\
x_{N-1} ~ y_{N-1} \)
  • On the 1st line, there are five integers N,M,T,L_A,L_B separated by spaces.
    • N represents the number of cities and satisfies N = 600.
    • M represents the number of roads and satisfies N-1 \le M \le 3 \times N-6.
    • T is the number of cities to visit and satisfies T = 600.
    • L_A represents the length of array A used to control the signals and satisfies N \le L_A \le 2 \times N.
    • L_B represents the length of array B used to control the signals and satisfies 4 \le L_B \le 24.
  • The following M lines contain information about the roads. the i-th road connects city u_i and v_i bidirectionally. 0 \le u_i \lt v_i \le N - 1, (u_i, v_i) \neq (u_j, v_j) (i \neq j) are satisfied.
  • The following line contains T integers separated by spaces. t_0, t_1, ..., t_{T - 1} are the cities that X plans to visit, and 0 \le t_i \le N - 1 (0 \le i \le T - 1), t_0 \neq 0, t_i \neq t_{i+1} (0 \le i \le T - 2) are satisfied.
  • The following N lines contain the coordinates of city i as (x_i, y_i) for the visualizer. The coordinates are integers and 0 \le x_i, y_i \le 1000, (x_i, y_i) \neq (x_j, y_j) (i \neq j) are satisfied. If unnecessary, you may skip reading them.
The given graph is a connected planar graph, and when the vertex i is placed at coordinates (x_i, y_i) and each edge is drawn as a line segment connecting its endpoints, it is guaranteed that no two edges have a common point other than their endpoints.

Output

On the 1st line, output the initial values of A as L_A integers between 0 and N - 1, inclusive separated by spaces.

In subsequent lines, output actions in the following format.

  • When performing a signal operation
    If the length of R_A and R_B is l (1 \le l \le L_B), the starting position of R_A is P_A (0 \le P_A \le L_A - l), and the starting position of R_B is P_B (0 \le P_B \le L_B - l), then output l, P_A, P_B separated by spaces following the leading s.
    l P_A P_B
  • When moving
    If the destination city is v, then output v separated by spaces following the leading m.
    v
    Note that the destination city must be directly connected by a road to the current city, and its signal must be green at that time.

Show example

Input Generation

Details of Input Generation

Let \mathrm{rand}(L,U) be a function that generates a uniform random integer between L and U, inclusive, and \mathrm{rand\_double}(L,U) be a function that generates a uniform random real number greater than or equal to L and less than U. Also, let the distance of two vertices u, v be \sqrt{(x_u - x_v)^2 + (y_u - y_v)^2}.

Graph Generation

Generate the parameters D_{vmin}, D_{emax}, and P_{remove} using \mathrm{rand}(20, 30), \mathrm{rand}(80, 140), and \mathrm{rand\_double}(0.0, 0.5) respectively.

Set N = 600 and perform the following operations in the order of i = 0, 1, \ldots N - 1 to generate the vertex set V.

  1. Generate x_i = \mathrm{rand}(0,1000), y_i = \mathrm{rand}(0,1000).
  2. Continue to choose (x_i, y_i) until there are no vertices in V that have a distance of less than D_{vmin} to (x_i, y_i).
  3. Add (x_i, y_i) to V.

Generate the edge set E as follows:

  1. List all vertex pairs within a distance of D_{emax} / 2, shuffle them randomly, and add each pair to E if they do not intersect with any already added edges. Here, for edges to intersect means that if vertex i is placed at coordinates (x_i, y_i) and edges are drawn as line segments connecting their endpoints, two edges share a common point other than their endpoints.
  2. List all vertex pairs with a distance greater than D_{emax} / 2 but less than D_{emax}, shuffle them randomly, and add each pair to E if they do not intersect with any already added edges.

If the graph (V, E) is not connected at this point, restart the generation from the creation of vertex set V.

Finally, for each edge e \in E in random order, if the graph remains connected after removing e, remove e from E with a probability of P_{remove}.

Generation of t

Generate t_0 with \mathrm{rand}(1, N - 1).

For i = 1, 2, \ldots, T - 1, generate t_i by choosing uniformly at random from all integers between 0 and N - 1, inclusive except t_{i -1}.

Generation of L_A and L_B

Generate L_A using \mathrm{rand}(N, 2 \times N).

Generate L_B using \mathrm{floor}{(\mathrm{rand\_double}(2.0, 5.0)^2)}. Here, \mathrm{floor}{(x)} represents the largest integer less than or equal to x.

You are not required to read it through.
Please refer to the source code of the input generator for implementation details.

Tools

  • Web Visualizer / Input Generator: For displaying animated visualizations.
  • Local Tester / Visualizer / Input Generator: Please set up a Rust language build environment to use this.
  • Sample code (C++, Python): Sample answers. Implemented as follows:
    • Set the initial values of array A such that the first N elements are 0, 1, \ldots, N - 1, and the remaining elements are 0.
    • For i = 0, 1, \ldots, T - 1, perform the following:
      • Using depth-first search prioritizing vertices with smaller Euclidean distances to the next destination t_i, find a path from the current position to t_i. On that path, perform signal operations with l = 1, P_B = 0 to turn the signals green one by one at each vertex, and then move to that vertex until reaching t_i.

Note that sharing visualization results or discussing solutions and considerations is forbidden until the contest ends.

The local tester writes outputs from your program directly to the output file.
Your program may output comment lines starting with #. The web version of the visualizer displays the comment lines with the corresponding output, which may be useful for debugging and analysis. Since the judge program ignores all comment lines, you can submit a program that outputs comment lines as is.


Sample Input

7 9 3 7 4
0 1
0 2
0 3
1 2
2 3
3 4
4 5
5 6
6 0
4 1 5
100 0
200 0
200 100
100 100
0 200
0 100
0 0
Please note that this input is for explanation purposes, and thus doesn't meet all of the constraints for input.

Sample Output

0 1 3 4 5 6 2
s 4 0 0
m 3
m 4
m 3
m 0
m 1
s 2 4 2
m 0
m 6
m 5
Output Description Visualization
0 1 3 4 5 6 2
Set the initial values of A to [0, 1, 3, 4, 5, 6, 2].
Initially, all signals are red.
s 4 0 0
Overwrite the subarray of length 4 starting from the 0-th element of B, with the subarray starting from the 0-th element of A. The value of B becomes [0, 1, 3, 4].
m 3
m 4
Move to the first destination vertex in the order 0 → 3 → 4.
m 3
m 0
m 1
Then, move to the next destination vertex in the order 4 → 3 → 0 → 1.
s 2 4 2
Overwrite the subarray of length 2 starting from the 2-nd element of B, with the subarray starting from the 4-th element of A. The value of B becomes [0, 1, 5, 6].
m 0
m 6
m 5
Move to the final destination vertex in the order 1 → 0 → 6 → 5.
The score for this test case is 2 since signal operation was performed twice.