| Codeforces Round 1032 (Div. 3) |
|---|
| Finished |
You are given an array of distinct integers $$$x_1, x_2, \ldots, x_n$$$ and an integer $$$s$$$.
Initially, you are at position $$$pos = s$$$ on the $$$X$$$ axis. In one step, you can perform exactly one of the following two actions:
A sequence of steps will be considered successful if, during the entire journey, you visit each position $$$x_i$$$ on the $$$X$$$ axis at least once. Note that the initial position $$$pos = s$$$ is also considered visited.
Your task is to determine the minimum number of steps in any successful sequence of steps.
Each test consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases. The description of the test cases follows.
The first line of each test case contains two integers $$$n$$$ and $$$s$$$ ($$$1 \leq n \leq 10$$$, $$$1 \leq s \leq 100$$$) — the number of positions to visit and the starting position.
The second line of each test case contains $$$n$$$ integers $$$x_1, x_2, \ldots, x_n$$$ ($$$1 \leq x_i \leq 100$$$). It is guaranteed that for all $$$1 \leq i \lt n$$$, it holds that $$$x_i \lt x_{i + 1}$$$.
For each test case, output the minimum number of steps in any successful sequence of steps.
121 111 211 122 12 32 21 32 31 23 11 2 33 21 3 43 31 2 34 31 2 3 105 51 2 3 6 76 61 2 3 9 10 11
0 1 1 2 3 2 2 4 2 11 8 15
In the first test case, no steps need to be taken, so the only visited position will be $$$1$$$.
In the second test case, the following path can be taken: $$$2 \rightarrow 1$$$. The number of steps is $$$1$$$.
In the third test case, the following path can be taken: $$$1 \rightarrow 2$$$. The number of steps is $$$1$$$.
In the fifth test case, the following path can be taken: $$$2 \rightarrow 1 \rightarrow 2 \rightarrow 3$$$. The number of steps is $$$3$$$.
| Name |
|---|


