CF1883A Morning
题目描述
你有 $t$ 个四位数密码,每次输入时你的光标在第一个数 $1$ 上,在一秒内你有两种操作:
- 按下光标输入一位密码。
- 将光标移到任意与当前数字相邻的数字。
这张图显示了你输入密码的设备,可以看到,$5$ 相邻的是 $4$ 和 $6$,而 $0$ 和 $1$ 只有一个相邻的数,分别是 $9$ 和 $2$。
计算输入给定密码需要的最少秒数。
输入格式
第一行输入一个整数 $t$ ($1 \le t \le 10^4$),表示有几个密码。
接着每行输入一个四位字符串,共 $t$ 行,表示密码,由 $0$ 到 $9$ 组成。
输出格式
共 $t$ 行,每行一个正整数,表示输入给定密码需要的最少秒数。
说明/提示
In the first test case, the cursor needs to be pressed $ 4 $ times.
In the second test case, it can be done in $ 9 $ seconds as follows:
- Press the cursor.
- Move the cursor to the digit $ 2 $ .
- Press the cursor.
- Move the cursor to the digit $ 3 $ .
- Press the cursor.
- Move the cursor to the digit $ 4 $ .
- Move the cursor to the digit $ 5 $ .
- Move the cursor to the digit $ 6 $ .
- Press the cursor.