CF1883A.Morning

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given a four-digit pin code consisting of digits from 00 to 99 that needs to be entered. Initially, the cursor points to the digit 11 . In one second, you can perform exactly one of the following two actions:

  • Press the cursor to display the current digit,
  • Move the cursor to any adjacent digit.

The image above shows the device you are using to enter the pin code. For example, for the digit 55 , the adjacent digits are 44 and 66 , and for the digit 00 , there is only one adjacent digit, 99 .

Determine the minimum number of seconds required to enter the given four-digit pin code.

输入格式

Each test consists of multiple test cases. The first line contains a single integer tt ( 1t1041 \leq t \leq 10^4 ) - the number of the test cases. This is followed by their description.

The single line of each test case describes the pin code as a string of length 44 , consisting of digits from 00 to 99 .

输出格式

For each test case, output the minimum number of seconds required to enter the given pin code.

输入输出样例

  • 输入#1

    10
    1111
    1236
    1010
    1920
    9273
    0000
    7492
    8543
    0294
    8361

    输出#1

    4
    9
    31
    27
    28
    13
    25
    16
    33
    24

说明/提示

In the first test case, the cursor needs to be pressed 44 times.

In the second test case, it can be done in 99 seconds as follows:

  • Press the cursor.
  • Move the cursor to the digit 22 .
  • Press the cursor.
  • Move the cursor to the digit 33 .
  • Press the cursor.
  • Move the cursor to the digit 44 .
  • Move the cursor to the digit 55 .
  • Move the cursor to the digit 66 .
  • Press the cursor.
首页